From fbbb3ccd6de3a96e71b623c369f89b97ed8e916a Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 5 Nov 2021 16:21:34 -0700 Subject: [PATCH 1/8] Use bytes proto accaddress --- docs/core/proto-docs.md | 4 +- go.mod | 1 + go.sum | 3 + proto/kava/pricefeed/v1beta1/pricefeed.proto | 19 +++- third_party/proto/cosmos_proto/cosmos.proto | 10 +- x/pricefeed/keeper/keeper.go | 4 +- x/pricefeed/keeper/msg_server.go | 5 +- x/pricefeed/types/genesis_test.go | 20 ++-- x/pricefeed/types/key.go | 4 +- x/pricefeed/types/market.go | 12 +- x/pricefeed/types/market_test.go | 14 +-- x/pricefeed/types/pricefeed.pb.go | 114 ++++++++++--------- 12 files changed, 115 insertions(+), 95 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index edcab84a6c..48d5658ab1 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -664,7 +664,7 @@ Market defines an asset in the pricefeed. | `market_id` | [string](#string) | | | | `base_asset` | [string](#string) | | | | `quote_asset` | [string](#string) | | | -| `oracles` | [string](#string) | repeated | | +| `oracles` | [bytes](#bytes) | repeated | | | `active` | [bool](#bool) | | | @@ -681,7 +681,7 @@ PostedPrice defines a price for market posted by a specific oracle. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `market_id` | [string](#string) | | | -| `oracle_address` | [string](#string) | | | +| `oracle_address` | [bytes](#bytes) | | | | `price` | [string](#string) | | | | `expiry` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | diff --git a/go.mod b/go.mod index b43942abbf..697ae6e245 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/kava-labs/kava go 1.16 require ( + github.com/cosmos/cosmos-proto v0.0.0-20211020182451-c7ca7198c2f8 github.com/cosmos/cosmos-sdk v0.44.3 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 diff --git a/go.sum b/go.sum index f1e37fd2c1..e977af3ceb 100644 --- a/go.sum +++ b/go.sum @@ -173,6 +173,8 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cosmos/cosmos-proto v0.0.0-20211020182451-c7ca7198c2f8 h1:NYYAiqXciz9JMAibyzVV5SbaaoBOEtu25Wuh9rX2YdA= +github.com/cosmos/cosmos-proto v0.0.0-20211020182451-c7ca7198c2f8/go.mod h1:g2Q3cd94kOBVRAv7ahdtO27yUc4cpNuHGnI40qanl1k= github.com/cosmos/cosmos-sdk v0.44.3 h1:F71n1jCqPi4F0wXg8AU4AUdUF8llw0x3D3o6aLt/j2A= github.com/cosmos/cosmos-sdk v0.44.3/go.mod h1:bA3+VenaR/l/vDiYzaiwbWvRPWHMBX2jG0ygiFtiBp0= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -1241,6 +1243,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/proto/kava/pricefeed/v1beta1/pricefeed.proto b/proto/kava/pricefeed/v1beta1/pricefeed.proto index cdeb54aada..1dddf6c61e 100644 --- a/proto/kava/pricefeed/v1beta1/pricefeed.proto +++ b/proto/kava/pricefeed/v1beta1/pricefeed.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package kava.pricefeed.v1beta1; +import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; @@ -10,11 +11,14 @@ option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; message Market { option (gogoproto.goproto_stringer) = false; - string market_id = 1 [(gogoproto.customname) = "MarketID"]; - string base_asset = 2; - string quote_asset = 3; - repeated string oracles = 4; - bool active = 5; + string market_id = 1 [(gogoproto.customname) = "MarketID"]; + string base_asset = 2; + string quote_asset = 3; + repeated bytes oracles = 4 [ + (cosmos_proto.scalar) = "cosmos.AddressBytes", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + bool active = 5; } // PostedPrice defines a price for market posted by a specific oracle. @@ -22,7 +26,10 @@ message PostedPrice { option (gogoproto.goproto_stringer) = false; string market_id = 1 [(gogoproto.customname) = "MarketID"]; - string oracle_address = 2; + bytes oracle_address = 2 [ + (cosmos_proto.scalar) = "cosmos.AddressBytes", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; string price = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; google.protobuf.Timestamp expiry = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; } diff --git a/third_party/proto/cosmos_proto/cosmos.proto b/third_party/proto/cosmos_proto/cosmos.proto index 167b170757..682d98af60 100644 --- a/third_party/proto/cosmos_proto/cosmos.proto +++ b/third_party/proto/cosmos_proto/cosmos.proto @@ -3,14 +3,16 @@ package cosmos_proto; import "google/protobuf/descriptor.proto"; -option go_package = "github.com/regen-network/cosmos-proto"; +option go_package = "github.com/cosmos/cosmos-proto"; extend google.protobuf.MessageOptions { - string interface_type = 93001; - - string implements_interface = 93002; + // implements_interface is used to annotate interface implementations + string implements_interface = 93001; } extend google.protobuf.FieldOptions { + // accepts_interface is used to annote fields that accept interfaces string accepts_interface = 93001; + // scalar is used to define scalar types + string scalar = 93002; } diff --git a/x/pricefeed/keeper/keeper.go b/x/pricefeed/keeper/keeper.go index 63215b5bf7..4f598c2025 100644 --- a/x/pricefeed/keeper/keeper.go +++ b/x/pricefeed/keeper/keeper.go @@ -49,7 +49,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // SetPrice updates the posted price for a specific oracle func (k Keeper) SetPrice( ctx sdk.Context, - oracle string, + oracle sdk.AccAddress, MarketID string, price sdk.Dec, expiry time.Time) (types.PostedPrice, error) { @@ -67,7 +67,7 @@ func (k Keeper) SetPrice( sdk.NewEvent( types.EventTypeOracleUpdatedPrice, sdk.NewAttribute(types.AttributeMarketID, MarketID), - sdk.NewAttribute(types.AttributeOracle, oracle), + sdk.NewAttribute(types.AttributeOracle, oracle.String()), sdk.NewAttribute(types.AttributeMarketPrice, price.String()), sdk.NewAttribute(types.AttributeExpiry, expiry.UTC().String()), ), diff --git a/x/pricefeed/keeper/msg_server.go b/x/pricefeed/keeper/msg_server.go index cc6eae65fd..9e302df5d0 100644 --- a/x/pricefeed/keeper/msg_server.go +++ b/x/pricefeed/keeper/msg_server.go @@ -23,8 +23,7 @@ var _ types.MsgServer = msgServer{} func (k msgServer) PostPrice(goCtx context.Context, msg *types.MsgPostPrice) (*types.MsgPostPriceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Just to validate, we still use string version later - _, err := sdk.AccAddressFromBech32(msg.From) + from, err := sdk.AccAddressFromBech32(msg.From) if err != nil { return nil, err } @@ -34,7 +33,7 @@ func (k msgServer) PostPrice(goCtx context.Context, msg *types.MsgPostPrice) (*t return nil, err } - _, err = k.SetPrice(ctx, msg.From, msg.MarketID, msg.Price, msg.Expiry) + _, err = k.SetPrice(ctx, from, msg.MarketID, msg.Price, msg.Expiry) if err != nil { return nil, err } diff --git a/x/pricefeed/types/genesis_test.go b/x/pricefeed/types/genesis_test.go index 251aea626b..e9c9e632ad 100644 --- a/x/pricefeed/types/genesis_test.go +++ b/x/pricefeed/types/genesis_test.go @@ -32,9 +32,9 @@ func TestGenesisStateValidate(t *testing.T) { msg: "valid genesis", genesisState: NewGenesisState( NewParams([]Market{ - {"market", "xrp", "bnb", []string{addr.String()}, true}, + {"market", "xrp", "bnb", []sdk.AccAddress{addr}, true}, }), - []PostedPrice{NewPostedPrice("xrp", addr.String(), sdk.OneDec(), now)}, + []PostedPrice{NewPostedPrice("xrp", addr, sdk.OneDec(), now)}, ), expPass: true, }, @@ -42,9 +42,9 @@ func TestGenesisStateValidate(t *testing.T) { msg: "invalid param", genesisState: NewGenesisState( NewParams([]Market{ - {"", "xrp", "bnb", []string{addr.String()}, true}, + {"", "xrp", "bnb", []sdk.AccAddress{addr}, true}, }), - []PostedPrice{NewPostedPrice("xrp", addr.String(), sdk.OneDec(), now)}, + []PostedPrice{NewPostedPrice("xrp", addr, sdk.OneDec(), now)}, ), expPass: false, }, @@ -52,10 +52,10 @@ func TestGenesisStateValidate(t *testing.T) { msg: "dup market param", genesisState: NewGenesisState( NewParams([]Market{ - {"market", "xrp", "bnb", []string{addr.String()}, true}, - {"market", "xrp", "bnb", []string{addr.String()}, true}, + {"market", "xrp", "bnb", []sdk.AccAddress{addr}, true}, + {"market", "xrp", "bnb", []sdk.AccAddress{addr}, true}, }), - []PostedPrice{NewPostedPrice("xrp", addr.String(), sdk.OneDec(), now)}, + []PostedPrice{NewPostedPrice("xrp", addr, sdk.OneDec(), now)}, ), expPass: false, }, @@ -63,7 +63,7 @@ func TestGenesisStateValidate(t *testing.T) { msg: "invalid posted price", genesisState: NewGenesisState( NewParams([]Market{}), - []PostedPrice{NewPostedPrice("xrp", "", sdk.OneDec(), now)}, + []PostedPrice{NewPostedPrice("xrp", nil, sdk.OneDec(), now)}, ), expPass: false, }, @@ -72,8 +72,8 @@ func TestGenesisStateValidate(t *testing.T) { genesisState: NewGenesisState( NewParams([]Market{}), []PostedPrice{ - NewPostedPrice("xrp", addr.String(), sdk.OneDec(), now), - NewPostedPrice("xrp", addr.String(), sdk.OneDec(), now), + NewPostedPrice("xrp", addr, sdk.OneDec(), now), + NewPostedPrice("xrp", addr, sdk.OneDec(), now), }, ), expPass: false, diff --git a/x/pricefeed/types/key.go b/x/pricefeed/types/key.go index c12520946b..95f06c37d1 100644 --- a/x/pricefeed/types/key.go +++ b/x/pricefeed/types/key.go @@ -1,5 +1,7 @@ package types +import sdk "github.com/cosmos/cosmos-sdk/types" + const ( // ModuleName The name that will be used throughout the module ModuleName = "pricefeed" @@ -39,7 +41,7 @@ func RawPriceMarketKey(marketId string) []byte { } // RawPriceKey returns the prefix for the raw price -func RawPriceKey(marketId string, oracleAddr string) []byte { +func RawPriceKey(marketId string, oracleAddr sdk.AccAddress) []byte { parts := [][]byte{ RawPriceFeedPrefix, []byte(marketId), diff --git a/x/pricefeed/types/market.go b/x/pricefeed/types/market.go index f8a3a36e28..58122f1c3b 100644 --- a/x/pricefeed/types/market.go +++ b/x/pricefeed/types/market.go @@ -10,7 +10,7 @@ import ( ) // NewMarket returns a new Market -func NewMarket(id, base, quote string, oracles []string, active bool) Market { +func NewMarket(id, base, quote string, oracles []sdk.AccAddress, active bool) Market { return Market{ MarketID: id, BaseAsset: base, @@ -47,10 +47,10 @@ func (m Market) Validate() error { if len(oracle) == 0 { return fmt.Errorf("oracle %d is empty", i) } - if seenOracles[oracle] { + if seenOracles[oracle.String()] { return fmt.Errorf("duplicated oracle %s", oracle) } - seenOracles[oracle] = true + seenOracles[oracle.String()] = true } return nil } @@ -77,7 +77,7 @@ func NewCurrentPrice(MarketID string, price sdk.Dec) CurrentPrice { } // NewPostedPrice returns a new PostedPrice -func NewPostedPrice(MarketID string, oracle string, price sdk.Dec, expiry time.Time) PostedPrice { +func NewPostedPrice(MarketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPrice { return PostedPrice{ MarketID: MarketID, OracleAddress: oracle, @@ -108,14 +108,14 @@ func (pp PostedPrice) Validate() error { func ValidatePostedPrices(pps []PostedPrice) error { seenPrices := make(map[string]bool) for _, pp := range pps { - if pp.OracleAddress != "" && seenPrices[pp.MarketID+pp.OracleAddress] { + if !pp.OracleAddress.Empty() && seenPrices[pp.MarketID+pp.OracleAddress.String()] { return fmt.Errorf("duplicated posted price for marked id %s and oracle address %s", pp.MarketID, pp.OracleAddress) } if err := pp.Validate(); err != nil { return err } - seenPrices[pp.MarketID+pp.OracleAddress] = true + seenPrices[pp.MarketID+pp.OracleAddress.String()] = true } return nil diff --git a/x/pricefeed/types/market_test.go b/x/pricefeed/types/market_test.go index e2f6259349..54bc397395 100644 --- a/x/pricefeed/types/market_test.go +++ b/x/pricefeed/types/market_test.go @@ -28,7 +28,7 @@ func TestMarketValidate(t *testing.T) { MarketID: "market", BaseAsset: "xrp", QuoteAsset: "bnb", - Oracles: []string{addr.String()}, + Oracles: []sdk.AccAddress{addr}, Active: true, }, true, @@ -64,7 +64,7 @@ func TestMarketValidate(t *testing.T) { MarketID: "market", BaseAsset: "xrp", QuoteAsset: "bnb", - Oracles: []string{""}, + Oracles: []sdk.AccAddress{nil}, }, false, }, @@ -74,7 +74,7 @@ func TestMarketValidate(t *testing.T) { MarketID: "market", BaseAsset: "xrp", QuoteAsset: "bnb", - Oracles: []string{addr.String(), addr.String()}, + Oracles: []sdk.AccAddress{addr, addr}, }, false, }, @@ -108,7 +108,7 @@ func TestPostedPriceValidate(t *testing.T) { "valid posted price", PostedPrice{ MarketID: "market", - OracleAddress: addr.String(), + OracleAddress: addr, Price: sdk.OneDec(), Expiry: now, }, @@ -125,7 +125,7 @@ func TestPostedPriceValidate(t *testing.T) { "invalid oracle", PostedPrice{ MarketID: "market", - OracleAddress: "", + OracleAddress: sdk.AccAddress{}, }, false, }, @@ -133,7 +133,7 @@ func TestPostedPriceValidate(t *testing.T) { "invalid price", PostedPrice{ MarketID: "market", - OracleAddress: addr.String(), + OracleAddress: addr, Price: sdk.NewDec(-1), }, false, @@ -142,7 +142,7 @@ func TestPostedPriceValidate(t *testing.T) { "zero expiry time ", PostedPrice{ MarketID: "market", - OracleAddress: addr.String(), + OracleAddress: addr, Price: sdk.OneDec(), Expiry: time.Time{}, }, diff --git a/x/pricefeed/types/pricefeed.pb.go b/x/pricefeed/types/pricefeed.pb.go index a6cb4fd244..323af16f98 100644 --- a/x/pricefeed/types/pricefeed.pb.go +++ b/x/pricefeed/types/pricefeed.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -30,11 +31,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Market defines an asset in the pricefeed. type Market struct { - MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` - BaseAsset string `protobuf:"bytes,2,opt,name=base_asset,json=baseAsset,proto3" json:"base_asset,omitempty"` - QuoteAsset string `protobuf:"bytes,3,opt,name=quote_asset,json=quoteAsset,proto3" json:"quote_asset,omitempty"` - Oracles []string `protobuf:"bytes,4,rep,name=oracles,proto3" json:"oracles,omitempty"` - Active bool `protobuf:"varint,5,opt,name=active,proto3" json:"active,omitempty"` + MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + BaseAsset string `protobuf:"bytes,2,opt,name=base_asset,json=baseAsset,proto3" json:"base_asset,omitempty"` + QuoteAsset string `protobuf:"bytes,3,opt,name=quote_asset,json=quoteAsset,proto3" json:"quote_asset,omitempty"` + Oracles []github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,rep,name=oracles,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"oracles,omitempty"` + Active bool `protobuf:"varint,5,opt,name=active,proto3" json:"active,omitempty"` } func (m *Market) Reset() { *m = Market{} } @@ -90,7 +91,7 @@ func (m *Market) GetQuoteAsset() string { return "" } -func (m *Market) GetOracles() []string { +func (m *Market) GetOracles() []github_com_cosmos_cosmos_sdk_types.AccAddress { if m != nil { return m.Oracles } @@ -106,10 +107,10 @@ func (m *Market) GetActive() bool { // PostedPrice defines a price for market posted by a specific oracle. type PostedPrice struct { - MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` - OracleAddress string `protobuf:"bytes,2,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` - Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` - Expiry time.Time `protobuf:"bytes,4,opt,name=expiry,proto3,stdtime" json:"expiry"` + MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + OracleAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=oracle_address,json=oracleAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"oracle_address,omitempty"` + Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` + Expiry time.Time `protobuf:"bytes,4,opt,name=expiry,proto3,stdtime" json:"expiry"` } func (m *PostedPrice) Reset() { *m = PostedPrice{} } @@ -151,11 +152,11 @@ func (m *PostedPrice) GetMarketID() string { return "" } -func (m *PostedPrice) GetOracleAddress() string { +func (m *PostedPrice) GetOracleAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { if m != nil { return m.OracleAddress } - return "" + return nil } func (m *PostedPrice) GetExpiry() time.Time { @@ -222,34 +223,37 @@ func init() { } var fileDescriptor_188809b7a903b86f = []byte{ - // 431 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x31, 0x6f, 0xd4, 0x30, - 0x18, 0x8d, 0xdb, 0xeb, 0x71, 0xe7, 0x2b, 0x0c, 0x11, 0xaa, 0xa2, 0x93, 0x48, 0xa2, 0x4a, 0x54, - 0x41, 0xa8, 0xb6, 0x0a, 0x1b, 0x62, 0x69, 0x38, 0x86, 0x0e, 0x48, 0x55, 0xc4, 0xc4, 0x72, 0x72, - 0x92, 0xaf, 0x21, 0xba, 0x0b, 0x0e, 0xb6, 0x73, 0x6a, 0x7f, 0x00, 0x7b, 0x47, 0x46, 0x76, 0xfe, - 0x48, 0xc7, 0x8e, 0x88, 0xe1, 0x40, 0xb9, 0x89, 0x7f, 0x81, 0x6c, 0x27, 0xb4, 0xeb, 0x89, 0xc9, - 0xdf, 0xf7, 0xde, 0xb3, 0xfd, 0x9e, 0x3f, 0xe3, 0xa3, 0x05, 0x5b, 0x31, 0x5a, 0x8b, 0x32, 0x83, - 0x0b, 0x80, 0x9c, 0xae, 0x4e, 0x52, 0x50, 0xec, 0xe4, 0x0e, 0x21, 0xb5, 0xe0, 0x8a, 0xbb, 0x07, - 0x5a, 0x47, 0xee, 0xd0, 0x4e, 0x37, 0x7d, 0x5c, 0xf0, 0x82, 0x1b, 0x09, 0xd5, 0x95, 0x55, 0x4f, - 0x83, 0x82,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6a, 0x90, 0x64, 0x06, 0x59, 0x62, 0x37, 0xbb, 0xaf, - 0xf1, 0x10, 0x2e, 0xeb, 0x52, 0x5c, 0x79, 0x83, 0x10, 0x45, 0x93, 0x17, 0x53, 0x62, 0xe7, 0x40, - 0xfa, 0x39, 0x90, 0xf7, 0xfd, 0x1c, 0xe2, 0x91, 0xbe, 0xe2, 0xfa, 0x57, 0x80, 0x92, 0x6e, 0x4f, - 0x97, 0xf5, 0x0b, 0xc2, 0xfb, 0x6f, 0x1a, 0x21, 0xe0, 0x93, 0xda, 0x3a, 0xec, 0xbf, 0x14, 0x3b, - 0xff, 0x91, 0xc2, 0xfa, 0x88, 0xdf, 0xde, 0xb4, 0x3e, 0xba, 0x6d, 0x7d, 0xf4, 0xbb, 0xf5, 0xd1, - 0xf5, 0xc6, 0x77, 0x6e, 0x37, 0xbe, 0xf3, 0x63, 0xe3, 0x3b, 0x1f, 0x9e, 0xdf, 0x3b, 0x4e, 0xff, - 0xca, 0xe3, 0x25, 0x4b, 0xa5, 0xa9, 0xe8, 0xe5, 0xbd, 0x9f, 0x6c, 0xce, 0x4d, 0x87, 0x26, 0xfa, - 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xbb, 0xe2, 0x63, 0xe8, 0x02, 0x00, 0x00, + // 471 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xf7, 0xa5, 0x69, 0x48, 0x2e, 0x81, 0xc1, 0xa0, 0xca, 0x44, 0xc2, 0x8e, 0x3a, 0x54, 0x41, + 0x28, 0xb6, 0x0a, 0x1b, 0x62, 0x89, 0x09, 0x12, 0x1d, 0x90, 0x2a, 0x8b, 0x89, 0x25, 0x3a, 0x9f, + 0x5f, 0x8d, 0x95, 0x98, 0x33, 0x77, 0x97, 0xa8, 0xf9, 0x00, 0xec, 0x1d, 0x19, 0xf9, 0x0e, 0xf0, + 0x21, 0x3a, 0x56, 0x4c, 0x88, 0x21, 0xa0, 0xe4, 0x33, 0xb0, 0x30, 0xa1, 0xfb, 0x63, 0xda, 0x91, + 0x8a, 0x4e, 0x7e, 0xef, 0xf7, 0x7e, 0xef, 0x3d, 0xff, 0x7e, 0x7a, 0x87, 0x0f, 0x66, 0x64, 0x49, + 0xa2, 0x8a, 0x17, 0x14, 0x4e, 0x00, 0xb2, 0x68, 0x79, 0x98, 0x82, 0x24, 0x87, 0x97, 0x48, 0x58, + 0x71, 0x26, 0x99, 0xbb, 0xa7, 0x78, 0xe1, 0x25, 0x6a, 0x79, 0xfd, 0xfb, 0x94, 0x89, 0x92, 0x89, + 0xa9, 0x66, 0x45, 0x26, 0x31, 0x2d, 0xfd, 0x7b, 0x39, 0xcb, 0x99, 0xc1, 0x55, 0x64, 0xd1, 0x20, + 0x67, 0x2c, 0x9f, 0x43, 0xa4, 0xb3, 0x74, 0x71, 0x12, 0xc9, 0xa2, 0x04, 0x21, 0x49, 0x59, 0x19, + 0xc2, 0xfe, 0x2f, 0x84, 0x5b, 0xaf, 0x08, 0x9f, 0x81, 0x74, 0x1f, 0xe2, 0x4e, 0xa9, 0xa3, 0x69, + 0x91, 0x79, 0x68, 0x80, 0x86, 0x9d, 0xb8, 0xb7, 0x59, 0x07, 0x6d, 0x53, 0x3e, 0x9a, 0x24, 0x6d, + 0x53, 0x3e, 0xca, 0xdc, 0x07, 0x18, 0xa7, 0x44, 0xc0, 0x94, 0x08, 0x01, 0xd2, 0x6b, 0x28, 0x6e, + 0xd2, 0x51, 0xc8, 0x58, 0x01, 0x6e, 0x80, 0xbb, 0xef, 0x17, 0x4c, 0xd6, 0xf5, 0x1d, 0x5d, 0xc7, + 0x1a, 0x32, 0x84, 0x14, 0xdf, 0x62, 0x9c, 0xd0, 0x39, 0x08, 0xaf, 0x39, 0xd8, 0x19, 0xf6, 0xe2, + 0x97, 0xbf, 0xd7, 0xc1, 0x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ad, 0xef, 0x5c, 0x6c, 0x7d, 0xe7, 0xdb, + 0xd6, 0x77, 0xde, 0x3c, 0xba, 0x32, 0x4e, 0x3d, 0xa2, 0xd1, 0x9c, 0xa4, 0x42, 0x47, 0xd1, 0xe9, + 0x95, 0x87, 0xa7, 0xe7, 0xa6, 0x2d, 0x2d, 0xfd, 0xc9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, + 0xfe, 0x02, 0xbd, 0x97, 0x03, 0x00, 0x00, } func (m *Market) Marshal() (dAtA []byte, err error) { @@ -440,8 +444,8 @@ func (m *Market) Size() (n int) { n += 1 + l + sovPricefeed(uint64(l)) } if len(m.Oracles) > 0 { - for _, s := range m.Oracles { - l = len(s) + for _, b := range m.Oracles { + l = len(b) n += 1 + l + sovPricefeed(uint64(l)) } } @@ -622,7 +626,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Oracles", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPricefeed @@ -632,23 +636,23 @@ func (m *Market) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthPricefeed } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthPricefeed } if postIndex > l { return io.ErrUnexpectedEOF } - m.Oracles = append(m.Oracles, string(dAtA[iNdEx:postIndex])) + m.Oracles = append(m.Oracles, make([]byte, postIndex-iNdEx)) + copy(m.Oracles[len(m.Oracles)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 0 { @@ -756,7 +760,7 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OracleAddress", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPricefeed @@ -766,23 +770,25 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthPricefeed } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthPricefeed } if postIndex > l { return io.ErrUnexpectedEOF } - m.OracleAddress = string(dAtA[iNdEx:postIndex]) + m.OracleAddress = append(m.OracleAddress[:0], dAtA[iNdEx:postIndex]...) + if m.OracleAddress == nil { + m.OracleAddress = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { From 655a71cee5fbad2922a14c26c37d7068c943d759 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Fri, 5 Nov 2021 16:48:47 -0700 Subject: [PATCH 2/8] Update keeper and base files to use sdk.AccAddress --- x/pricefeed/genesis_test.go | 8 +---- x/pricefeed/grpc_query.go | 7 +++- x/pricefeed/grpc_query_test.go | 45 ++++++++++++-------------- x/pricefeed/integration_test.go | 10 +++--- x/pricefeed/keeper/integration_test.go | 8 ++--- x/pricefeed/keeper/keeper_test.go | 40 +++++++++++------------ x/pricefeed/keeper/params.go | 10 ++---- x/pricefeed/keeper/params_test.go | 20 +++--------- x/pricefeed/keeper/querier_test.go | 8 ++--- x/pricefeed/msg_server.go | 4 +-- x/pricefeed/msg_server_test.go | 12 +++---- x/pricefeed/types/key.go | 2 +- x/pricefeed/types/key_test.go | 14 ++++---- 13 files changed, 82 insertions(+), 106 deletions(-) diff --git a/x/pricefeed/genesis_test.go b/x/pricefeed/genesis_test.go index ee6d01748f..865142590b 100644 --- a/x/pricefeed/genesis_test.go +++ b/x/pricefeed/genesis_test.go @@ -37,17 +37,11 @@ func (suite *GenesisTestSuite) TestValidGenState() { }) _, addrs := app.GeneratePrivKeyAddressPairs(10) - var strAddrs []string - - for _, addr := range addrs { - strAddrs = append(strAddrs, addr.String()) - } - // Must create a new TestApp or InitChain will panic with index already set suite.tApp = app.NewTestApp() suite.NotPanics(func() { suite.tApp.InitializeFromGenesisStates( - NewPricefeedGenStateWithOracles(strAddrs), + NewPricefeedGenStateWithOracles(addrs), ) }) } diff --git a/x/pricefeed/grpc_query.go b/x/pricefeed/grpc_query.go index b438c0a623..e5cbc209d8 100644 --- a/x/pricefeed/grpc_query.go +++ b/x/pricefeed/grpc_query.go @@ -87,8 +87,13 @@ func (k QueryServer) Oracles(c context.Context, req *types.QueryOraclesRequest) return nil, status.Error(codes.NotFound, "invalid market ID") } + var strOracles []string + for _, oracle := range oracles { + strOracles = append(strOracles, oracle.String()) + } + return &types.QueryOraclesResponse{ - Oracles: oracles, + Oracles: strOracles, }, nil } diff --git a/x/pricefeed/grpc_query_test.go b/x/pricefeed/grpc_query_test.go index 215c7e87c2..72377bfcd7 100644 --- a/x/pricefeed/grpc_query_test.go +++ b/x/pricefeed/grpc_query_test.go @@ -21,6 +21,7 @@ type grpcQueryTestSuite struct { keeper keeper.Keeper queryServer types.QueryServer addrs []sdk.AccAddress + strAddrs []string now time.Time } @@ -34,12 +35,18 @@ func (suite *grpcQueryTestSuite) SetupTest() { _, addrs := app.GeneratePrivKeyAddressPairs(5) suite.addrs = addrs + var strAddrs []string + for _, a := range addrs { + strAddrs = append(strAddrs, a.String()) + } + suite.strAddrs = strAddrs + suite.now = time.Now().UTC() } func (suite *grpcQueryTestSuite) setTestParams() { params := types.NewParams([]types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }) suite.keeper.SetParams(suite.ctx, params) } @@ -52,7 +59,7 @@ func (suite *grpcQueryTestSuite) TestGrpcParams() { }{ {"default params", types.DefaultParams(), true}, {"test params", types.NewParams([]types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }), true}, } @@ -125,19 +132,19 @@ func (suite *grpcQueryTestSuite) TestGrpcRawPrices() { []types.PostedPrice{ types.NewPostedPrice( "tstusd", - suite.addrs[0].String(), + suite.addrs[0], sdk.MustNewDecFromStr("0.33"), suite.now.Add(time.Hour*1), ), types.NewPostedPrice( "tstusd", - suite.addrs[1].String(), + suite.addrs[1], sdk.MustNewDecFromStr("0.35"), suite.now.Add(time.Hour*1), ), types.NewPostedPrice( "tstusd", - suite.addrs[2].String(), + suite.addrs[2], sdk.MustNewDecFromStr("0.34"), suite.now.Add(time.Hour*1), ), @@ -155,7 +162,7 @@ func (suite *grpcQueryTestSuite) TestGrpcRawPrices_InvalidMarket() { func (suite *grpcQueryTestSuite) TestGrpcOracles_Empty() { params := types.NewParams([]types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }) suite.keeper.SetParams(suite.ctx, params) @@ -163,38 +170,28 @@ func (suite *grpcQueryTestSuite) TestGrpcOracles_Empty() { suite.NoError(err) suite.Empty(res.Oracles) - var oracles []string - for _, a := range suite.addrs { - oracles = append(oracles, a.String()) - } - params = types.NewParams([]types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: oracles, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: suite.addrs, Active: true}, }) suite.keeper.SetParams(suite.ctx, params) res, err = suite.queryServer.Oracles(sdk.WrapSDKContext(suite.ctx), &types.QueryOraclesRequest{MarketId: "tstusd"}) suite.NoError(err) - suite.ElementsMatch(res.Oracles, oracles) + suite.ElementsMatch(suite.strAddrs, res.Oracles) _, err = suite.queryServer.Oracles(sdk.WrapSDKContext(suite.ctx), &types.QueryOraclesRequest{MarketId: "invalid"}) suite.Equal("rpc error: code = NotFound desc = invalid market ID", err.Error()) } func (suite *grpcQueryTestSuite) TestGrpcOracles() { - var oracles []string - for _, a := range suite.addrs { - oracles = append(oracles, a.String()) - } - params := types.NewParams([]types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: oracles, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: suite.addrs, Active: true}, }) suite.keeper.SetParams(suite.ctx, params) res, err := suite.queryServer.Oracles(sdk.WrapSDKContext(suite.ctx), &types.QueryOraclesRequest{MarketId: "tstusd"}) suite.NoError(err) - suite.ElementsMatch(res.Oracles, oracles) + suite.ElementsMatch(suite.strAddrs, res.Oracles) } func (suite *grpcQueryTestSuite) TestGrpcOracles_InvalidMarket() { @@ -206,7 +203,7 @@ func (suite *grpcQueryTestSuite) TestGrpcOracles_InvalidMarket() { func (suite *grpcQueryTestSuite) TestGrpcMarkets() { params := types.NewParams([]types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }) suite.keeper.SetParams(suite.ctx, params) @@ -219,19 +216,19 @@ func (suite *grpcQueryTestSuite) TestGrpcMarkets() { func (suite *grpcQueryTestSuite) setTstPrice() { _, err := suite.keeper.SetPrice( - suite.ctx, suite.addrs[0].String(), "tstusd", + suite.ctx, suite.addrs[0], "tstusd", sdk.MustNewDecFromStr("0.33"), suite.now.Add(time.Hour*1)) suite.NoError(err) _, err = suite.keeper.SetPrice( - suite.ctx, suite.addrs[1].String(), "tstusd", + suite.ctx, suite.addrs[1], "tstusd", sdk.MustNewDecFromStr("0.35"), suite.now.Add(time.Hour*1)) suite.NoError(err) _, err = suite.keeper.SetPrice( - suite.ctx, suite.addrs[2].String(), "tstusd", + suite.ctx, suite.addrs[2], "tstusd", sdk.MustNewDecFromStr("0.34"), suite.now.Add(time.Hour*1)) suite.NoError(err) diff --git a/x/pricefeed/integration_test.go b/x/pricefeed/integration_test.go index 81ca92b00b..35c0381934 100644 --- a/x/pricefeed/integration_test.go +++ b/x/pricefeed/integration_test.go @@ -13,20 +13,20 @@ func NewPricefeedGen() types.GenesisState { return types.GenesisState{ Params: types.Params{ Markets: []types.Market{ - {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []string{}, Active: true}, - {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, + {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, }, PostedPrices: []types.PostedPrice{ { MarketID: "btc:usd", - OracleAddress: "", + OracleAddress: sdk.AccAddress{}, Price: sdk.MustNewDecFromStr("8000.00"), Expiry: time.Now().Add(1 * time.Hour), }, { MarketID: "xrp:usd", - OracleAddress: "", + OracleAddress: sdk.AccAddress{}, Price: sdk.MustNewDecFromStr("0.25"), Expiry: time.Now().Add(1 * time.Hour), }, @@ -39,7 +39,7 @@ func NewPricefeedGenStateMulti() app.GenesisState { return app.GenesisState{types.ModuleName: types.ModuleCdc.LegacyAmino.MustMarshalJSON(pfGenesis)} } -func NewPricefeedGenStateWithOracles(addrs []string) app.GenesisState { +func NewPricefeedGenStateWithOracles(addrs []sdk.AccAddress) app.GenesisState { pfGenesis := types.GenesisState{ Params: types.Params{ Markets: []types.Market{ diff --git a/x/pricefeed/keeper/integration_test.go b/x/pricefeed/keeper/integration_test.go index a3611c26c5..e2c1cff64b 100644 --- a/x/pricefeed/keeper/integration_test.go +++ b/x/pricefeed/keeper/integration_test.go @@ -13,20 +13,20 @@ func NewPricefeedGenStateMulti() app.GenesisState { pfGenesis := types.GenesisState{ Params: types.Params{ Markets: []types.Market{ - {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []string{}, Active: true}, - {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, + {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, }, PostedPrices: []types.PostedPrice{ { MarketID: "btc:usd", - OracleAddress: "", + OracleAddress: sdk.AccAddress{}, Price: sdk.MustNewDecFromStr("8000.00"), Expiry: time.Now().Add(1 * time.Hour), }, { MarketID: "xrp:usd", - OracleAddress: "", + OracleAddress: sdk.AccAddress{}, Price: sdk.MustNewDecFromStr("0.25"), Expiry: time.Now().Add(1 * time.Hour), }, diff --git a/x/pricefeed/keeper/keeper_test.go b/x/pricefeed/keeper/keeper_test.go index fb37cea074..220a2f613b 100644 --- a/x/pricefeed/keeper/keeper_test.go +++ b/x/pricefeed/keeper/keeper_test.go @@ -22,7 +22,7 @@ func TestKeeper_SetGetMarket(t *testing.T) { mp := types.Params{ Markets: []types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, } keeper.SetParams(ctx, mp) @@ -38,8 +38,8 @@ func TestKeeper_SetGetMarket(t *testing.T) { mp = types.Params{ Markets: []types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, - {MarketID: "tst2usd", BaseAsset: "tst2", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, + {MarketID: "tst2usd", BaseAsset: "tst2", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, } keeper.SetParams(ctx, mp) @@ -61,20 +61,20 @@ func TestKeeper_GetSetPrice(t *testing.T) { mp := types.Params{ Markets: []types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, } keeper.SetParams(ctx, mp) prices := []struct { - oracle string + oracle sdk.AccAddress marketID string price sdk.Dec total int }{ - {addrs[0].String(), "tstusd", sdk.MustNewDecFromStr("0.33"), 1}, - {addrs[1].String(), "tstusd", sdk.MustNewDecFromStr("0.35"), 2}, - {addrs[0].String(), "tstusd", sdk.MustNewDecFromStr("0.37"), 2}, + {addrs[0], "tstusd", sdk.MustNewDecFromStr("0.33"), 1}, + {addrs[1], "tstusd", sdk.MustNewDecFromStr("0.35"), 2}, + {addrs[0], "tstusd", sdk.MustNewDecFromStr("0.37"), 2}, } for _, p := range prices { @@ -97,7 +97,7 @@ func TestKeeper_GetSetPrice(t *testing.T) { // Find the oracle and require price to be same for _, rp := range rawPrices { - if p.oracle == rp.OracleAddress { + if p.oracle.Equals(rp.OracleAddress) { require.Equal(t, p.price, rp.Price) } } @@ -114,39 +114,39 @@ func TestKeeper_GetSetCurrentPrice(t *testing.T) { mp := types.Params{ Markets: []types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, } keeper.SetParams(ctx, mp) _, err := keeper.SetPrice( - ctx, addrs[0].String(), "tstusd", + ctx, addrs[0], "tstusd", sdk.MustNewDecFromStr("0.33"), time.Now().Add(time.Hour*1)) require.NoError(t, err) _, err = keeper.SetPrice( - ctx, addrs[1].String(), "tstusd", + ctx, addrs[1], "tstusd", sdk.MustNewDecFromStr("0.35"), time.Now().Add(time.Hour*1)) require.NoError(t, err) _, err = keeper.SetPrice( - ctx, addrs[2].String(), "tstusd", + ctx, addrs[2], "tstusd", sdk.MustNewDecFromStr("0.34"), time.Now().Add(time.Hour*1)) require.NoError(t, err) // Add an expired one which should fail _, err = keeper.SetPrice( - ctx, addrs[3].String(), "tstusd", + ctx, addrs[3], "tstusd", sdk.MustNewDecFromStr("0.9"), ctx.BlockTime().Add(-time.Hour*1)) require.Error(t, err) // Add a non-expired price, but will not be counted when BlockTime is changed _, err = keeper.SetPrice( - ctx, addrs[3].String(), "tstusd", + ctx, addrs[3], "tstusd", sdk.MustNewDecFromStr("0.9"), time.Now().Add(time.Minute*30)) require.NoError(t, err) @@ -172,7 +172,7 @@ func TestKeeper_GetSetCurrentPrice(t *testing.T) { // Even number of oracles _, err = keeper.SetPrice( - ctx, addrs[4].String(), "tstusd", + ctx, addrs[4], "tstusd", sdk.MustNewDecFromStr("0.36"), time.Now().Add(time.Hour*1)) require.NoError(t, err) @@ -204,25 +204,25 @@ func TestKeeper_ExpiredSetCurrentPrices(t *testing.T) { mp := types.Params{ Markets: []types.Market{ - {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, } keeper.SetParams(ctx, mp) _, err := keeper.SetPrice( - ctx, addrs[0].String(), "tstusd", + ctx, addrs[0], "tstusd", sdk.MustNewDecFromStr("0.33"), time.Now().Add(time.Hour*1)) require.NoError(t, err) _, err = keeper.SetPrice( - ctx, addrs[1].String(), "tstusd", + ctx, addrs[1], "tstusd", sdk.MustNewDecFromStr("0.35"), time.Now().Add(time.Hour*1)) require.NoError(t, err) _, err = keeper.SetPrice( - ctx, addrs[2].String(), "tstusd", + ctx, addrs[2], "tstusd", sdk.MustNewDecFromStr("0.34"), time.Now().Add(time.Hour*1)) require.NoError(t, err) diff --git a/x/pricefeed/keeper/params.go b/x/pricefeed/keeper/params.go index d26e78d79d..e8d27ca6bb 100644 --- a/x/pricefeed/keeper/params.go +++ b/x/pricefeed/keeper/params.go @@ -69,14 +69,10 @@ func (k Keeper) GetAuthorizedAddresses(ctx sdk.Context) []sdk.AccAddress { for _, m := range k.GetMarkets(ctx) { for _, o := range m.Oracles { // de-dup list of oracles - if _, found := uniqueOracles[o]; !found { - addr, err := sdk.AccAddressFromBech32(o) - if err != nil { - panic(err) - } - oracles = append(oracles, addr) + if _, found := uniqueOracles[o.String()]; !found { + oracles = append(oracles, o) } - uniqueOracles[o] = true + uniqueOracles[o.String()] = true } } return oracles diff --git a/x/pricefeed/keeper/params_test.go b/x/pricefeed/keeper/params_test.go index 93a1c5236a..5edec22831 100644 --- a/x/pricefeed/keeper/params_test.go +++ b/x/pricefeed/keeper/params_test.go @@ -19,8 +19,7 @@ type KeeperTestSuite struct { suite.Suite keeper keeper.Keeper - addrs []string - app app.TestApp + addrs []sdk.AccAddress ctx sdk.Context } @@ -34,17 +33,12 @@ func (suite *KeeperTestSuite) SetupTest() { suite.ctx = ctx _, addrs := app.GeneratePrivKeyAddressPairs(10) - var strAddrs []string - for _, addr := range addrs { - strAddrs = append(strAddrs, addr.String()) - } - - suite.addrs = strAddrs + suite.addrs = addrs } func (suite *KeeperTestSuite) TestGetSetOracles() { params := suite.keeper.GetParams(suite.ctx) - suite.Equal([]string(nil), params.Markets[0].Oracles) + suite.Equal([]sdk.AccAddress(nil), params.Markets[0].Oracles) params.Markets[0].Oracles = suite.addrs suite.NotPanics(func() { suite.keeper.SetParams(suite.ctx, params) }) @@ -58,15 +52,11 @@ func (suite *KeeperTestSuite) TestGetSetOracles() { func (suite *KeeperTestSuite) TestGetAuthorizedAddresses() { _, oracles := app.GeneratePrivKeyAddressPairs(5) - var strOracles []string - for _, addr := range oracles { - strOracles = append(strOracles, addr.String()) - } params := types.Params{ Markets: []types.Market{ - {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: strOracles[:3], Active: true}, - {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: strOracles[2:], Active: true}, + {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: oracles[:3], Active: true}, + {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: oracles[2:], Active: true}, {MarketID: "xrp:usd:30", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: nil, Active: true}, }, } diff --git a/x/pricefeed/keeper/querier_test.go b/x/pricefeed/keeper/querier_test.go index a2976a91e5..8584e31dfa 100644 --- a/x/pricefeed/keeper/querier_test.go +++ b/x/pricefeed/keeper/querier_test.go @@ -16,8 +16,8 @@ func (suite *KeeperTestSuite) TestQuerierGetParams() { expParams := types.Params{ Markets: []types.Market{ - {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []string{}, Active: true}, - {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []string{}, Active: true}, + {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, + {MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }, } var p types.Params @@ -128,8 +128,8 @@ func (suite *KeeperTestSuite) TestQuerierGetMarkets() { suite.NotNil(bz) expMarkets := []types.Market{ - types.NewMarket("btc:usd", "btc", "usd", []string(nil), true), - types.NewMarket("xrp:usd", "xrp", "usd", []string(nil), true), + types.NewMarket("btc:usd", "btc", "usd", []sdk.AccAddress(nil), true), + types.NewMarket("xrp:usd", "xrp", "usd", []sdk.AccAddress(nil), true), } var p []types.Market diff --git a/x/pricefeed/msg_server.go b/x/pricefeed/msg_server.go index d703d18fa1..a65a81d370 100644 --- a/x/pricefeed/msg_server.go +++ b/x/pricefeed/msg_server.go @@ -29,12 +29,12 @@ func (k msgServer) PostPrice(goCtx context.Context, msg *types.MsgPostPrice) (*t return nil, err } - _, err = k.keeper.GetOracle(ctx, msg.MarketID, msg.From) + _, err = k.keeper.GetOracle(ctx, msg.MarketID, from) if err != nil { return nil, err } - _, err = k.keeper.SetPrice(ctx, msg.From, msg.MarketID, msg.Price, msg.Expiry) + _, err = k.keeper.SetPrice(ctx, from, msg.MarketID, msg.Price, msg.Expiry) if err != nil { return nil, err } diff --git a/x/pricefeed/msg_server_test.go b/x/pricefeed/msg_server_test.go index 960f0b991a..111f6f689e 100644 --- a/x/pricefeed/msg_server_test.go +++ b/x/pricefeed/msg_server_test.go @@ -20,12 +20,8 @@ func TestKeeper_PostPrice(t *testing.T) { k := tApp.GetPriceFeedKeeper() msgSrv := pricefeed.NewMsgServerImpl(k) - var strAddrs []string - for _, a := range addrs { - strAddrs = append(strAddrs, a.String()) - } - authorizedOracles := strAddrs[:2] - unauthorizedAddrs := strAddrs[2:] + authorizedOracles := addrs[:2] + unauthorizedAddrs := addrs[2:] mp := types.Params{ Markets: []types.Market{ @@ -38,7 +34,7 @@ func TestKeeper_PostPrice(t *testing.T) { tests := []struct { giveMsg string - giveOracle string + giveOracle sdk.AccAddress giveMarketId string giveExpiry time.Time wantAccepted bool @@ -53,7 +49,7 @@ func TestKeeper_PostPrice(t *testing.T) { for _, tt := range tests { t.Run(tt.giveMsg, func(t *testing.T) { // Use MsgServer over keeper methods directly to tests against valid oracles - msg := types.NewMsgPostPrice(tt.giveOracle, tt.giveMarketId, sdk.MustNewDecFromStr("0.5"), tt.giveExpiry) + msg := types.NewMsgPostPrice(tt.giveOracle.String(), tt.giveMarketId, sdk.MustNewDecFromStr("0.5"), tt.giveExpiry) _, err := msgSrv.PostPrice(sdk.WrapSDKContext(ctx), msg) if tt.wantAccepted { diff --git a/x/pricefeed/types/key.go b/x/pricefeed/types/key.go index 21b02c1b62..c8062ed514 100644 --- a/x/pricefeed/types/key.go +++ b/x/pricefeed/types/key.go @@ -44,7 +44,7 @@ func RawPriceIteratorKey(marketID string) []byte { func RawPriceKey(marketID string, oracleAddr sdk.AccAddress) []byte { return append( RawPriceIteratorKey(marketID), - lengthPrefixWithByte([]byte(oracleAddr))..., + lengthPrefixWithByte(oracleAddr)..., ) } diff --git a/x/pricefeed/types/key_test.go b/x/pricefeed/types/key_test.go index d60b3d4d18..0254638726 100644 --- a/x/pricefeed/types/key_test.go +++ b/x/pricefeed/types/key_test.go @@ -3,14 +3,17 @@ package types import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) func TestRawPriceKey_Iteration(t *testing.T) { - // An iterator key should only match price keys with the same market iteratorKey := RawPriceIteratorKey("kava:usd") + addr, err := sdk.AccAddressFromBech32("kava17e8afwcxk0k72hhr7xapugtf5xhxth0a6d5jwz") + require.NoError(t, err) + testCases := []struct { name string priceKey []byte @@ -18,17 +21,12 @@ func TestRawPriceKey_Iteration(t *testing.T) { }{ { name: "equal marketID is included in iteration", - priceKey: RawPriceKey("kava:usd", "kava17e8afwcxk0k72hhr7xapugtf5xhxth0a6d5jwz"), + priceKey: RawPriceKey("kava:usd", addr), expectErr: false, }, { name: "prefix overlapping marketID excluded from iteration", - priceKey: RawPriceKey("kava:usd:30", "kava17e8afwcxk0k72hhr7xapugtf5xhxth0a6d5jwz"), - expectErr: true, - }, - { - name: "injection via oracle address excluded from iteration", - priceKey: RawPriceKey("", "kava:usdkava17e8afwcxk0k72hhr7xapugtf5xhxth0a6d5jwz"), + priceKey: RawPriceKey("kava:usd:30", addr), expectErr: true, }, } From 4dc67a12e3d94521aefc5e1fbdeed485c690270f Mon Sep 17 00:00:00 2001 From: drklee3 Date: Mon, 8 Nov 2021 09:24:28 -0800 Subject: [PATCH 3/8] Update ante, key tests --- app/ante/ante_test.go | 7 +------ x/pricefeed/types/key_test.go | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index 25fdf7b79a..434fb64f1f 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -131,15 +131,10 @@ func TestAppAnteHandler(t *testing.T) { // TODO Test pricefeed oracles and bep3 deputy txs can always get into the mempool. func newPricefeedGenStateMulti(cdc codec.JSONCodec, oracles []sdk.AccAddress) app.GenesisState { - var oracleStrs []string - for _, o := range oracles { - oracleStrs = append(oracleStrs, o.String()) - } - pfGenesis := pricefeedtypes.GenesisState{ Params: pricefeedtypes.Params{ Markets: []pricefeedtypes.Market{ - {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: oracleStrs, Active: true}, + {MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: oracles, Active: true}, }, }, } diff --git a/x/pricefeed/types/key_test.go b/x/pricefeed/types/key_test.go index 0254638726..a18e17409d 100644 --- a/x/pricefeed/types/key_test.go +++ b/x/pricefeed/types/key_test.go @@ -11,8 +11,7 @@ func TestRawPriceKey_Iteration(t *testing.T) { // An iterator key should only match price keys with the same market iteratorKey := RawPriceIteratorKey("kava:usd") - addr, err := sdk.AccAddressFromBech32("kava17e8afwcxk0k72hhr7xapugtf5xhxth0a6d5jwz") - require.NoError(t, err) + addr := sdk.AccAddress("test addr") testCases := []struct { name string From 18ce002412fe808ab1531aace7c0f02236596aa1 Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Fri, 5 Nov 2021 15:21:37 +0000 Subject: [PATCH 4/8] Split proto types draft cherry-pick --- docs/core/proto-docs.md | 73 +- proto/kava/pricefeed/v1beta1/genesis.proto | 8 +- proto/kava/pricefeed/v1beta1/query.proto | 29 +- .../v1beta1/{pricefeed.proto => store.proto} | 6 + x/pricefeed/genesis.go | 1 + x/pricefeed/integration_test.go | 4 +- x/pricefeed/keeper/grpc_query.go | 108 +++ x/pricefeed/types/genesis.pb.go | 275 +------ x/pricefeed/types/query.pb.go | 777 ++++++++++++++++-- .../types/{pricefeed.pb.go => store.pb.go} | 472 ++++++++--- 10 files changed, 1301 insertions(+), 452 deletions(-) rename proto/kava/pricefeed/v1beta1/{pricefeed.proto => store.proto} (86%) create mode 100644 x/pricefeed/keeper/grpc_query.go rename x/pricefeed/types/{pricefeed.pb.go => store.pb.go} (69%) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 8bc6048964..00e96131fc 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -51,16 +51,18 @@ - [Query](#kava.kavadist.v1beta1.Query) -- [kava/pricefeed/v1beta1/pricefeed.proto](#kava/pricefeed/v1beta1/pricefeed.proto) +- [kava/pricefeed/v1beta1/store.proto](#kava/pricefeed/v1beta1/store.proto) - [CurrentPrice](#kava.pricefeed.v1beta1.CurrentPrice) - [Market](#kava.pricefeed.v1beta1.Market) + - [Params](#kava.pricefeed.v1beta1.Params) - [PostedPrice](#kava.pricefeed.v1beta1.PostedPrice) - [kava/pricefeed/v1beta1/genesis.proto](#kava/pricefeed/v1beta1/genesis.proto) - [GenesisState](#kava.pricefeed.v1beta1.GenesisState) - - [Params](#kava.pricefeed.v1beta1.Params) - [kava/pricefeed/v1beta1/query.proto](#kava/pricefeed/v1beta1/query.proto) + - [CurrentPriceResponse](#kava.pricefeed.v1beta1.CurrentPriceResponse) + - [PostedPriceResponse](#kava.pricefeed.v1beta1.PostedPriceResponse) - [QueryMarketsRequest](#kava.pricefeed.v1beta1.QueryMarketsRequest) - [QueryMarketsResponse](#kava.pricefeed.v1beta1.QueryMarketsResponse) - [QueryOraclesRequest](#kava.pricefeed.v1beta1.QueryOraclesRequest) @@ -662,10 +664,10 @@ Query defines the gRPC querier service. - +

Top

-## kava/pricefeed/v1beta1/pricefeed.proto +## kava/pricefeed/v1beta1/store.proto @@ -705,6 +707,21 @@ Market defines an asset in the pricefeed. + + +### Params +Params defines the parameters for the pricefeed module. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `markets` | [Market](#kava.pricefeed.v1beta1.Market) | repeated | | + + + + + + ### PostedPrice @@ -754,35 +771,55 @@ GenesisState defines the pricefeed module's genesis state. + - + + + + + -### Params -Params defines the parameters for the pricefeed module. + + + +

Top

+ +## kava/pricefeed/v1beta1/query.proto + + + + + +### CurrentPriceResponse +CurrentPriceResponse defines a current price for a particular market in the pricefeed +module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `markets` | [Market](#kava.pricefeed.v1beta1.Market) | repeated | | +| `market_id` | [string](#string) | | | +| `price` | [string](#string) | | | - - + - +### PostedPriceResponse +PostedPriceResponse defines a price for market posted by a specific oracle. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `market_id` | [string](#string) | | | +| `oracle_address` | [string](#string) | | | +| `price` | [string](#string) | | | +| `expiry` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | - -

Top

-## kava/pricefeed/v1beta1/query.proto @@ -891,7 +928,7 @@ QueryPriceResponse is the response type for the Query/Prices RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `price` | [CurrentPrice](#kava.pricefeed.v1beta1.CurrentPrice) | | | +| `price` | [CurrentPriceResponse](#kava.pricefeed.v1beta1.CurrentPriceResponse) | | | @@ -916,7 +953,7 @@ QueryPricesResponse is the response type for the Query/Prices RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `prices` | [CurrentPrice](#kava.pricefeed.v1beta1.CurrentPrice) | repeated | | +| `prices` | [CurrentPriceResponse](#kava.pricefeed.v1beta1.CurrentPriceResponse) | repeated | | @@ -947,7 +984,7 @@ method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `raw_prices` | [PostedPrice](#kava.pricefeed.v1beta1.PostedPrice) | repeated | | +| `raw_prices` | [PostedPriceResponse](#kava.pricefeed.v1beta1.PostedPriceResponse) | repeated | | diff --git a/proto/kava/pricefeed/v1beta1/genesis.proto b/proto/kava/pricefeed/v1beta1/genesis.proto index 0d14a544df..3e70fc088b 100644 --- a/proto/kava/pricefeed/v1beta1/genesis.proto +++ b/proto/kava/pricefeed/v1beta1/genesis.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package kava.pricefeed.v1beta1; -import "kava/pricefeed/v1beta1/pricefeed.proto"; +import "kava/pricefeed/v1beta1/store.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; @@ -15,9 +15,3 @@ message GenesisState { repeated PostedPrice posted_prices = 2 [(gogoproto.nullable) = false]; } - -// Params defines the parameters for the pricefeed module. -message Params { - option (gogoproto.goproto_stringer) = false; // false here because we define Stringer method in params.go - repeated Market markets = 1 [(gogoproto.nullable) = false]; -} diff --git a/proto/kava/pricefeed/v1beta1/query.proto b/proto/kava/pricefeed/v1beta1/query.proto index 5542840852..03b794e986 100644 --- a/proto/kava/pricefeed/v1beta1/query.proto +++ b/proto/kava/pricefeed/v1beta1/query.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package kava.pricefeed.v1beta1; -import "kava/pricefeed/v1beta1/genesis.proto"; -import "kava/pricefeed/v1beta1/pricefeed.proto"; +import "kava/pricefeed/v1beta1/store.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; option (gogoproto.equal_all) = true; @@ -66,7 +66,7 @@ message QueryPriceRequest { message QueryPriceResponse { option (gogoproto.goproto_getters) = false; - CurrentPrice price = 1 [(gogoproto.nullable) = false]; + CurrentPriceResponse price = 1 [(gogoproto.nullable) = false]; } // QueryPricesRequest is the request type for the Query/Prices RPC method. @@ -76,7 +76,7 @@ message QueryPricesRequest {} message QueryPricesResponse { option (gogoproto.goproto_getters) = false; - repeated CurrentPrice prices = 1 [(gogoproto.nullable) = false]; + repeated CurrentPriceResponse prices = 1 [(gogoproto.nullable) = false]; } // QueryRawPricesRequest is the request type for the Query/RawPrices RPC method. @@ -91,7 +91,7 @@ message QueryRawPricesRequest { message QueryRawPricesResponse { option (gogoproto.goproto_getters) = false; - repeated PostedPrice raw_prices = 1 [(gogoproto.nullable) = false]; + repeated PostedPriceResponse raw_prices = 1 [(gogoproto.nullable) = false]; } // QueryOraclesRequest is the request type for the Query/Oracles RPC method. @@ -119,3 +119,22 @@ message QueryMarketsResponse { // List of markets repeated Market markets = 1 [(gogoproto.nullable) = false]; } + +// PostedPriceResponse defines a price for market posted by a specific oracle. +message PostedPriceResponse { + option (gogoproto.goproto_stringer) = false; + + string market_id = 1 [(gogoproto.customname) = "MarketID"]; + string oracle_address = 2; + string price = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + google.protobuf.Timestamp expiry = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} + +// CurrentPriceResponse defines a current price for a particular market in the pricefeed +// module. +message CurrentPriceResponse { + 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]; +} diff --git a/proto/kava/pricefeed/v1beta1/pricefeed.proto b/proto/kava/pricefeed/v1beta1/store.proto similarity index 86% rename from proto/kava/pricefeed/v1beta1/pricefeed.proto rename to proto/kava/pricefeed/v1beta1/store.proto index 4ca81a806c..89ee4edfee 100644 --- a/proto/kava/pricefeed/v1beta1/pricefeed.proto +++ b/proto/kava/pricefeed/v1beta1/store.proto @@ -9,6 +9,12 @@ option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; option (gogoproto.equal_all) = true; option (gogoproto.verbose_equal_all) = true; +// Params defines the parameters for the pricefeed module. +message Params { + option (gogoproto.goproto_stringer) = false; // false here because we define Stringer method in params.go + repeated Market markets = 1 [(gogoproto.nullable) = false]; +} + // Market defines an asset in the pricefeed. message Market { option (gogoproto.goproto_stringer) = false; diff --git a/x/pricefeed/genesis.go b/x/pricefeed/genesis.go index f2cde37242..ebafb5ca14 100644 --- a/x/pricefeed/genesis.go +++ b/x/pricefeed/genesis.go @@ -2,6 +2,7 @@ package pricefeed import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/kava-labs/kava/x/pricefeed/keeper" "github.com/kava-labs/kava/x/pricefeed/types" ) diff --git a/x/pricefeed/integration_test.go b/x/pricefeed/integration_test.go index 35c0381934..b8d230f7e5 100644 --- a/x/pricefeed/integration_test.go +++ b/x/pricefeed/integration_test.go @@ -20,13 +20,13 @@ func NewPricefeedGen() types.GenesisState { PostedPrices: []types.PostedPrice{ { MarketID: "btc:usd", - OracleAddress: sdk.AccAddress{}, + OracleAddress: sdk.AccAddress("oracle1"), Price: sdk.MustNewDecFromStr("8000.00"), Expiry: time.Now().Add(1 * time.Hour), }, { MarketID: "xrp:usd", - OracleAddress: sdk.AccAddress{}, + OracleAddress: sdk.AccAddress("oracle2"), Price: sdk.MustNewDecFromStr("0.25"), Expiry: time.Now().Add(1 * time.Hour), }, diff --git a/x/pricefeed/keeper/grpc_query.go b/x/pricefeed/keeper/grpc_query.go new file mode 100644 index 0000000000..de9f371fa0 --- /dev/null +++ b/x/pricefeed/keeper/grpc_query.go @@ -0,0 +1,108 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/kava-labs/kava/x/pricefeed/types" +) + +var _ types.QueryServer = Keeper{} + +// Params implements the gRPC service handler for querying x/swap parameters. +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(c) + params := k.GetParams(sdkCtx) + + return &types.QueryParamsResponse{Params: params}, nil +} + +func (k Keeper) Price(c context.Context, req *types.QueryPriceRequest) (*types.QueryPriceResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + _, found := k.GetMarket(ctx, req.MarketId) + if !found { + return nil, status.Error(codes.InvalidArgument, "invalid market ID") + } + currentPrice, sdkErr := k.GetCurrentPrice(ctx, req.MarketId) + if sdkErr != nil { + return nil, sdkErr + } + + return &types.QueryPriceResponse{ + Price: types.CurrentPriceResponse{ + MarketID: currentPrice.MarketID, + Price: currentPrice.Price, + }}, nil + +} +func (k Keeper) Prices(c context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + var currentPrices []types.CurrentPriceResponse + + for _, cp := range k.GetCurrentPrices(ctx) { + currentPrices = append(currentPrices, types.CurrentPriceResponse{ + MarketID: cp.MarketID, + Price: cp.Price, + }) + } + + return &types.QueryPricesResponse{ + Prices: currentPrices, + }, nil +} + +func (k Keeper) RawPrices(c context.Context, req *types.QueryRawPricesRequest) (*types.QueryRawPricesResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + _, found := k.GetMarket(ctx, req.MarketId) + if !found { + return nil, status.Error(codes.NotFound, "invalid market ID") + } + + var prices []types.PostedPriceResponse + for _, rp := range k.GetRawPrices(ctx, req.MarketId) { + prices = append(prices, types.PostedPriceResponse{ + MarketID: rp.MarketID, + OracleAddress: rp.OracleAddress.String(), + Price: rp.Price, + Expiry: rp.Expiry, + }) + } + + return &types.QueryRawPricesResponse{ + RawPrices: prices, + }, nil +} + +func (k Keeper) Oracles(c context.Context, req *types.QueryOraclesRequest) (*types.QueryOraclesResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + oracles, err := k.GetOracles(ctx, req.MarketId) + if err != nil { + return nil, status.Error(codes.NotFound, "invalid market ID") + } + + return &types.QueryOraclesResponse{ + Oracles: oracles, + }, nil +} + +func (k Keeper) Markets(c context.Context, req *types.QueryMarketsRequest) (*types.QueryMarketsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + markets := k.GetMarkets(ctx) + + return &types.QueryMarketsResponse{ + Markets: markets, + }, nil +} diff --git a/x/pricefeed/types/genesis.pb.go b/x/pricefeed/types/genesis.pb.go index eb2e949a4b..06fad99beb 100644 --- a/x/pricefeed/types/genesis.pb.go +++ b/x/pricefeed/types/genesis.pb.go @@ -77,53 +77,8 @@ func (m *GenesisState) GetPostedPrices() []PostedPrice { return nil } -// Params defines the parameters for the pricefeed module. -type Params struct { - Markets []Market `protobuf:"bytes,1,rep,name=markets,proto3" json:"markets"` -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_fffec798191784d2, []int{1} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetMarkets() []Market { - if m != nil { - return m.Markets - } - return nil -} - func init() { proto.RegisterType((*GenesisState)(nil), "kava.pricefeed.v1beta1.GenesisState") - proto.RegisterType((*Params)(nil), "kava.pricefeed.v1beta1.Params") } func init() { @@ -131,25 +86,23 @@ func init() { } var fileDescriptor_fffec798191784d2 = []byte{ - // 285 bytes of a gzipped FileDescriptorProto + // 252 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x4e, 0x2c, 0x4b, 0xd4, 0x2f, 0x28, 0xca, 0x4c, 0x4e, 0x4d, 0x4b, 0x4d, 0x4d, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x03, 0xa9, 0xd2, 0x83, 0xab, 0xd2, 0x83, 0xaa, 0x92, 0x52, 0xc3, 0xa1, 0x1b, 0xa1, - 0x12, 0xac, 0x5f, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0x20, 0xa2, 0x4a, - 0x73, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0xf6, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0xd9, 0x70, 0xb1, - 0x15, 0x24, 0x16, 0x25, 0xe6, 0x16, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0xc9, 0xe9, 0x61, - 0xb7, 0x57, 0x2f, 0x00, 0xac, 0xca, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x1e, 0x21, - 0x3f, 0x2e, 0xde, 0x82, 0xfc, 0xe2, 0x92, 0xd4, 0x94, 0x78, 0xb0, 0x86, 0x62, 0x09, 0x26, 0x05, - 0x66, 0x0d, 0x6e, 0x23, 0x65, 0x9c, 0x86, 0x80, 0x15, 0x07, 0x80, 0xc4, 0xa1, 0x26, 0xf1, 0x14, - 0x20, 0x84, 0x8a, 0x95, 0xfc, 0xb8, 0xd8, 0x20, 0xf6, 0x08, 0xd9, 0x71, 0xb1, 0xe7, 0x26, 0x16, - 0x65, 0xa7, 0x96, 0x80, 0x1c, 0xc6, 0x8c, 0xcf, 0x61, 0xbe, 0x60, 0x65, 0x50, 0xe3, 0x60, 0x9a, - 0xac, 0x58, 0x66, 0x2c, 0x90, 0x67, 0x70, 0xf2, 0x7d, 0xf0, 0x50, 0x8e, 0x71, 0xc5, 0x23, 0x39, - 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, - 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4e, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x07, 0x59, 0xa0, 0x9b, 0x93, 0x98, 0x54, 0x0c, 0x66, - 0xe9, 0x57, 0x20, 0x85, 0x72, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x10, 0x8d, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x87, 0x5e, 0xda, 0xc2, 0x01, 0x00, 0x00, + 0x17, 0x12, 0x03, 0xa9, 0xd2, 0x83, 0xab, 0xd2, 0x83, 0xaa, 0x92, 0x52, 0xc2, 0xa1, 0xbb, 0xb8, + 0x24, 0xbf, 0x28, 0x15, 0xa2, 0x57, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, + 0x20, 0xa2, 0x4a, 0x73, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x76, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x0a, + 0xd9, 0x70, 0xb1, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x16, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, + 0xc9, 0xe9, 0x61, 0xb7, 0x53, 0x2f, 0x00, 0xac, 0xca, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, + 0xa8, 0x1e, 0x21, 0x3f, 0x2e, 0xde, 0x82, 0xfc, 0xe2, 0x92, 0xd4, 0x94, 0x78, 0xb0, 0x86, 0x62, + 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x65, 0x9c, 0x86, 0x80, 0x15, 0x07, 0x80, 0xc4, 0xa1, + 0x26, 0xf1, 0x14, 0x20, 0x84, 0x8a, 0x9d, 0x7c, 0x1f, 0x3c, 0x94, 0x63, 0x5c, 0xf1, 0x48, 0x8e, + 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xb4, 0xd3, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x41, 0x96, 0xe8, 0xe6, 0x24, 0x26, 0x15, 0x83, 0x59, + 0xfa, 0x15, 0x48, 0x21, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0xb4, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0xcb, 0x8a, 0x8d, 0x8f, 0x6e, 0x01, 0x00, 0x00, } func (this *GenesisState) VerboseEqual(that interface{}) error { @@ -222,70 +175,6 @@ func (this *GenesisState) Equal(that interface{}) bool { } return true } -func (this *Params) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Params) - if !ok { - that2, ok := that.(Params) - if ok { - that1 = &that2 - } else { - return fmt.Errorf("that is not of type *Params") - } - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Params but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Params but is not nil && this == nil") - } - if len(this.Markets) != len(that1.Markets) { - return fmt.Errorf("Markets this(%v) Not Equal that(%v)", len(this.Markets), len(that1.Markets)) - } - for i := range this.Markets { - if !this.Markets[i].Equal(&that1.Markets[i]) { - return fmt.Errorf("Markets this[%v](%v) Not Equal that[%v](%v)", i, this.Markets[i], i, that1.Markets[i]) - } - } - return nil -} -func (this *Params) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Params) - if !ok { - that2, ok := that.(Params) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if len(this.Markets) != len(that1.Markets) { - return false - } - for i := range this.Markets { - if !this.Markets[i].Equal(&that1.Markets[i]) { - return false - } - } - return true -} func (m *GenesisState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -333,43 +222,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Markets) > 0 { - for iNdEx := len(m.Markets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Markets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -398,21 +250,6 @@ func (m *GenesisState) Size() (n int) { return n } -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Markets) > 0 { - for _, e := range m.Markets { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - return n -} - func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -536,90 +373,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } -func (m *Params) 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 ErrIntOverflowGenesis - } - 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: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Markets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Markets = append(m.Markets, Market{}) - if err := m.Markets[len(m.Markets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/pricefeed/types/query.pb.go b/x/pricefeed/types/query.pb.go index 9e5f88b905..3ae243fe3c 100644 --- a/x/pricefeed/types/query.pb.go +++ b/x/pricefeed/types/query.pb.go @@ -6,22 +6,27 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "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. @@ -146,7 +151,7 @@ var xxx_messageInfo_QueryPriceRequest proto.InternalMessageInfo // QueryPriceResponse is the response type for the Query/Prices RPC method. type QueryPriceResponse struct { - Price CurrentPrice `protobuf:"bytes,1,opt,name=price,proto3" json:"price"` + Price CurrentPriceResponse `protobuf:"bytes,1,opt,name=price,proto3" json:"price"` } func (m *QueryPriceResponse) Reset() { *m = QueryPriceResponse{} } @@ -221,7 +226,7 @@ var xxx_messageInfo_QueryPricesRequest proto.InternalMessageInfo // QueryPricesResponse is the response type for the Query/Prices RPC method. type QueryPricesResponse struct { - Prices []CurrentPrice `protobuf:"bytes,1,rep,name=prices,proto3" json:"prices"` + Prices []CurrentPriceResponse `protobuf:"bytes,1,rep,name=prices,proto3" json:"prices"` } func (m *QueryPricesResponse) Reset() { *m = QueryPricesResponse{} } @@ -298,7 +303,7 @@ var xxx_messageInfo_QueryRawPricesRequest proto.InternalMessageInfo // QueryRawPricesResponse is the response type for the Query/RawPrices RPC // method. type QueryRawPricesResponse struct { - RawPrices []PostedPrice `protobuf:"bytes,1,rep,name=raw_prices,json=rawPrices,proto3" json:"raw_prices"` + RawPrices []PostedPriceResponse `protobuf:"bytes,1,rep,name=raw_prices,json=rawPrices,proto3" json:"raw_prices"` } func (m *QueryRawPricesResponse) Reset() { *m = QueryRawPricesResponse{} } @@ -487,6 +492,113 @@ func (m *QueryMarketsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryMarketsResponse proto.InternalMessageInfo +// PostedPriceResponse defines a price for market posted by a specific oracle. +type PostedPriceResponse struct { + MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + OracleAddress string `protobuf:"bytes,2,opt,name=oracle_address,json=oracleAddress,proto3" json:"oracle_address,omitempty"` + Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` + Expiry time.Time `protobuf:"bytes,4,opt,name=expiry,proto3,stdtime" json:"expiry"` +} + +func (m *PostedPriceResponse) Reset() { *m = PostedPriceResponse{} } +func (*PostedPriceResponse) ProtoMessage() {} +func (*PostedPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_84567be3085e4c6c, []int{12} +} +func (m *PostedPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PostedPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PostedPriceResponse.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 *PostedPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostedPriceResponse.Merge(m, src) +} +func (m *PostedPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *PostedPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PostedPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PostedPriceResponse proto.InternalMessageInfo + +func (m *PostedPriceResponse) GetMarketID() string { + if m != nil { + return m.MarketID + } + return "" +} + +func (m *PostedPriceResponse) GetOracleAddress() string { + if m != nil { + return m.OracleAddress + } + return "" +} + +func (m *PostedPriceResponse) GetExpiry() time.Time { + if m != nil { + return m.Expiry + } + return time.Time{} +} + +// CurrentPriceResponse defines a current price for a particular market in the pricefeed +// module. +type CurrentPriceResponse struct { + MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` +} + +func (m *CurrentPriceResponse) Reset() { *m = CurrentPriceResponse{} } +func (*CurrentPriceResponse) ProtoMessage() {} +func (*CurrentPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_84567be3085e4c6c, []int{13} +} +func (m *CurrentPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CurrentPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CurrentPriceResponse.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 *CurrentPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CurrentPriceResponse.Merge(m, src) +} +func (m *CurrentPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *CurrentPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CurrentPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CurrentPriceResponse proto.InternalMessageInfo + +func (m *CurrentPriceResponse) GetMarketID() string { + if m != nil { + return m.MarketID + } + return "" +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "kava.pricefeed.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "kava.pricefeed.v1beta1.QueryParamsResponse") @@ -500,6 +612,8 @@ func init() { proto.RegisterType((*QueryOraclesResponse)(nil), "kava.pricefeed.v1beta1.QueryOraclesResponse") proto.RegisterType((*QueryMarketsRequest)(nil), "kava.pricefeed.v1beta1.QueryMarketsRequest") proto.RegisterType((*QueryMarketsResponse)(nil), "kava.pricefeed.v1beta1.QueryMarketsResponse") + proto.RegisterType((*PostedPriceResponse)(nil), "kava.pricefeed.v1beta1.PostedPriceResponse") + proto.RegisterType((*CurrentPriceResponse)(nil), "kava.pricefeed.v1beta1.CurrentPriceResponse") } func init() { @@ -507,48 +621,57 @@ func init() { } var fileDescriptor_84567be3085e4c6c = []byte{ - // 643 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x95, 0xb1, 0x6f, 0xd3, 0x40, - 0x14, 0xc6, 0x73, 0xd0, 0x24, 0xe4, 0x98, 0x38, 0xd2, 0xaa, 0x32, 0xc8, 0x29, 0xa6, 0x2a, 0x90, - 0x34, 0xb6, 0x9a, 0x8a, 0x0a, 0x55, 0x08, 0xa1, 0xb0, 0xc0, 0x50, 0x01, 0xd9, 0x40, 0x95, 0xa2, - 0x4b, 0x72, 0xb8, 0x56, 0x13, 0x9f, 0x7b, 0x76, 0x1a, 0x2a, 0xc4, 0x82, 0x18, 0x60, 0x40, 0x42, - 0x30, 0xb1, 0xc1, 0xc6, 0x9f, 0xd2, 0xb1, 0x12, 0x0b, 0x13, 0x2a, 0x09, 0x7f, 0x08, 0xca, 0xdd, - 0xb3, 0x89, 0x43, 0x9d, 0xba, 0x9b, 0xfb, 0xf4, 0xbe, 0xef, 0xfb, 0xdd, 0xbb, 0x7b, 0x0d, 0x36, - 0x76, 0xe9, 0x3e, 0xb5, 0x3c, 0xe1, 0xb4, 0xd9, 0x0b, 0xc6, 0x3a, 0xd6, 0xfe, 0x5a, 0x8b, 0x05, - 0x74, 0xcd, 0xda, 0xeb, 0x33, 0x71, 0x60, 0x7a, 0x82, 0x07, 0x9c, 0x2c, 0x8c, 0x7b, 0xcc, 0xa8, - 0xc7, 0x84, 0x1e, 0x6d, 0x39, 0x41, 0x6b, 0x33, 0x97, 0xf9, 0x8e, 0xaf, 0xd4, 0xda, 0x4a, 0x42, - 0xd7, 0x3f, 0x3f, 0xd5, 0x57, 0xb4, 0xb9, 0xcd, 0xe5, 0xa7, 0x35, 0xfe, 0x82, 0xea, 0x55, 0x9b, - 0x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xb3, 0x87, 0x10, 0xdf, - 0x31, 0x6d, 0x35, 0x5d, 0x33, 0xd0, 0xad, 0x4b, 0xba, 0x2a, 0xa9, 0x24, 0xd1, 0xc1, 0x96, 0xc5, - 0xd8, 0x3e, 0x20, 0x9c, 0x87, 0x85, 0x3a, 0x85, 0x2d, 0xbe, 0x8d, 0xa7, 0xb0, 0x4d, 0xed, 0xa8, - 0x71, 0x43, 0xb2, 0x5d, 0x23, 0xa5, 0x24, 0x36, 0x58, 0xc6, 0xfa, 0xd6, 0xf1, 0x6f, 0x1d, 0x7d, - 0x1f, 0xea, 0xe8, 0x70, 0xa8, 0xa3, 0xa3, 0xa1, 0x8e, 0x8e, 0x87, 0x3a, 0xfa, 0x38, 0xd2, 0x33, - 0x47, 0x23, 0x3d, 0xf3, 0x73, 0xa4, 0x67, 0x9e, 0x57, 0x6c, 0x27, 0xd8, 0xe9, 0xb7, 0xcc, 0x36, - 0xef, 0x49, 0xb3, 0x6a, 0x97, 0xb6, 0x7c, 0x65, 0xfb, 0x72, 0xc2, 0x38, 0x38, 0xf0, 0x98, 0xdf, - 0xca, 0xc9, 0xdf, 0xb9, 0xf5, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbd, 0xf8, 0x1e, 0x9d, 0xa7, - 0x07, 0x00, 0x00, + // 794 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0x3b, 0x50, 0x5a, 0x3a, 0xbf, 0x3f, 0x89, 0x43, 0x21, 0x4d, 0x35, 0x5b, 0x6c, 0x22, + 0x0a, 0xa5, 0xbb, 0x01, 0x22, 0x31, 0xc4, 0x98, 0x58, 0x39, 0x88, 0x09, 0x11, 0x1b, 0x2f, 0x1a, + 0x13, 0x32, 0xed, 0x0e, 0xb5, 0x81, 0x76, 0x96, 0x99, 0x2d, 0x7f, 0x62,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7, 0xb7, + 0xef, 0xf2, 0xba, 0xec, 0x44, 0x94, 0x54, 0x00, 0x99, 0x56, 0x20, 0x93, 0x64, 0x22, 0x14, 0x44, + 0xbd, 0x47, 0xeb, 0x59, 0xe7, 0x4c, 0x9e, 0xeb, 0x05, 0xa9, 0x30, 0x89, 0x20, 0x15, 0x75, 0x41, + 0x01, 0x47, 0x89, 0xb0, 0x20, 0x0d, 0xf0, 0x11, 0xe1, 0x54, 0xc7, 0x8f, 0x48, 0xf1, 0x54, 0x89, + 0xe3, 0x9e, 0x97, 0x35, 0xa3, 0xa6, 0x03, 0xd4, 0x75, 0x05, 0x65, 0x91, 0x62, 0x18, 0x94, 0xa0, + 0x9b, 0x3d, 0xf6, 0xf5, 0x1e, 0xe1, 0x24, 0xf8, 0x10, 0x39, 0x7d, 0x09, 0x41, 0x9f, 0xcb, 0x4e, + 0x46, 0x4b, 0x06, 0xba, 0x19, 0x45, 0x57, 0x24, 0x85, 0x30, 0x3a, 0x70, 0xba, 0x00, 0xdb, 0x0e, + 0xc2, 0x49, 0x30, 0xb5, 0x33, 0xd8, 0x82, 0x8e, 0x78, 0x06, 0xdb, 0x31, 0x9f, 0xcc, 0x5f, 0x55, + 0x6c, 0x97, 0x49, 0x2e, 0x8c, 0x0d, 0x0c, 0xb1, 0xb4, 0x78, 0xf8, 0xdd, 0x40, 0x9f, 0xda, 0x06, + 0xda, 0x6b, 0x1b, 0x68, 0xbf, 0x6d, 0xa0, 0xc3, 0xb6, 0x81, 0x76, 0x8f, 0x8c, 0xd8, 0xfe, 0x91, + 0x11, 0xfb, 0x72, 0x64, 0xc4, 0x1e, 0x17, 0xba, 0x5e, 0xb7, 0xd7, 0xac, 0xb8, 0x46, 0x2b, 0x52, + 0xb7, 0xdd, 0xea, 0x6a, 0xac, 0x9e, 0x79, 0x25, 0xa1, 0x1c, 0x69, 0xe6, 0x57, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x4a, 0xaa, 0xf0, 0x48, 0x3a, 0x09, 0x00, 0x00, } func (this *QueryParamsRequest) VerboseEqual(that interface{}) error { @@ -1221,6 +1344,138 @@ func (this *QueryMarketsResponse) Equal(that interface{}) bool { } return true } +func (this *PostedPriceResponse) VerboseEqual(that interface{}) error { + if that == nil { + if this == nil { + return nil + } + return fmt.Errorf("that == nil && this != nil") + } + + that1, ok := that.(*PostedPriceResponse) + if !ok { + that2, ok := that.(PostedPriceResponse) + if ok { + that1 = &that2 + } else { + return fmt.Errorf("that is not of type *PostedPriceResponse") + } + } + if that1 == nil { + if this == nil { + return nil + } + return fmt.Errorf("that is type *PostedPriceResponse but is nil && this != nil") + } else if this == nil { + return fmt.Errorf("that is type *PostedPriceResponse but is not nil && this == nil") + } + if this.MarketID != that1.MarketID { + return fmt.Errorf("MarketID this(%v) Not Equal that(%v)", this.MarketID, that1.MarketID) + } + if this.OracleAddress != that1.OracleAddress { + return fmt.Errorf("OracleAddress this(%v) Not Equal that(%v)", this.OracleAddress, that1.OracleAddress) + } + if !this.Price.Equal(that1.Price) { + return fmt.Errorf("Price this(%v) Not Equal that(%v)", this.Price, that1.Price) + } + if !this.Expiry.Equal(that1.Expiry) { + return fmt.Errorf("Expiry this(%v) Not Equal that(%v)", this.Expiry, that1.Expiry) + } + return nil +} +func (this *PostedPriceResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PostedPriceResponse) + if !ok { + that2, ok := that.(PostedPriceResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.MarketID != that1.MarketID { + return false + } + if this.OracleAddress != that1.OracleAddress { + return false + } + if !this.Price.Equal(that1.Price) { + return false + } + if !this.Expiry.Equal(that1.Expiry) { + return false + } + return true +} +func (this *CurrentPriceResponse) VerboseEqual(that interface{}) error { + if that == nil { + if this == nil { + return nil + } + return fmt.Errorf("that == nil && this != nil") + } + + that1, ok := that.(*CurrentPriceResponse) + if !ok { + that2, ok := that.(CurrentPriceResponse) + if ok { + that1 = &that2 + } else { + return fmt.Errorf("that is not of type *CurrentPriceResponse") + } + } + if that1 == nil { + if this == nil { + return nil + } + return fmt.Errorf("that is type *CurrentPriceResponse but is nil && this != nil") + } else if this == nil { + return fmt.Errorf("that is type *CurrentPriceResponse but is not nil && this == nil") + } + if this.MarketID != that1.MarketID { + return fmt.Errorf("MarketID this(%v) Not Equal that(%v)", this.MarketID, that1.MarketID) + } + if !this.Price.Equal(that1.Price) { + return fmt.Errorf("Price this(%v) Not Equal that(%v)", this.Price, that1.Price) + } + return nil +} +func (this *CurrentPriceResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CurrentPriceResponse) + if !ok { + that2, ok := that.(CurrentPriceResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.MarketID != that1.MarketID { + return false + } + if !this.Price.Equal(that1.Price) { + return false + } + return true +} // Reference imports to suppress errors if they are not otherwise used. var _ context.Context @@ -1862,6 +2117,101 @@ func (m *QueryMarketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PostedPriceResponse) 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 *PostedPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PostedPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Expiry, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiry):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintQuery(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x22 + { + size := m.Price.Size() + i -= size + if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.OracleAddress) > 0 { + i -= len(m.OracleAddress) + copy(dAtA[i:], m.OracleAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.OracleAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.MarketID) > 0 { + i -= len(m.MarketID) + copy(dAtA[i:], m.MarketID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MarketID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CurrentPriceResponse) 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 *CurrentPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CurrentPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Price.Size() + i -= size + if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.MarketID) > 0 { + i -= len(m.MarketID) + copy(dAtA[i:], m.MarketID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MarketID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2021,6 +2371,42 @@ func (m *QueryMarketsResponse) Size() (n int) { return n } +func (m *PostedPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MarketID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.OracleAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovQuery(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiry) + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *CurrentPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MarketID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2433,7 +2819,7 @@ func (m *QueryPricesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Prices = append(m.Prices, CurrentPrice{}) + m.Prices = append(m.Prices, CurrentPriceResponse{}) if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2599,7 +2985,7 @@ func (m *QueryRawPricesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RawPrices = append(m.RawPrices, PostedPrice{}) + m.RawPrices = append(m.RawPrices, PostedPriceResponse{}) if err := m.RawPrices[len(m.RawPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2923,6 +3309,303 @@ func (m *QueryMarketsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *PostedPriceResponse) 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 ErrIntOverflowQuery + } + 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: PostedPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PostedPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OracleAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Expiry, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CurrentPriceResponse) 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 ErrIntOverflowQuery + } + 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: CurrentPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CurrentPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/pricefeed/types/pricefeed.pb.go b/x/pricefeed/types/store.pb.go similarity index 69% rename from x/pricefeed/types/pricefeed.pb.go rename to x/pricefeed/types/store.pb.go index 88149c337d..8e783f5dc6 100644 --- a/x/pricefeed/types/pricefeed.pb.go +++ b/x/pricefeed/types/store.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: kava/pricefeed/v1beta1/pricefeed.proto +// source: kava/pricefeed/v1beta1/store.proto package types @@ -30,6 +30,50 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// Params defines the parameters for the pricefeed module. +type Params struct { + Markets []Market `protobuf:"bytes,1,rep,name=markets,proto3" json:"markets"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_9df40639f5e16f9a, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetMarkets() []Market { + if m != nil { + return m.Markets + } + return nil +} + // Market defines an asset in the pricefeed. type Market struct { MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` @@ -42,7 +86,7 @@ type Market struct { func (m *Market) Reset() { *m = Market{} } func (*Market) ProtoMessage() {} func (*Market) Descriptor() ([]byte, []int) { - return fileDescriptor_188809b7a903b86f, []int{0} + return fileDescriptor_9df40639f5e16f9a, []int{1} } func (m *Market) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,7 +161,7 @@ type PostedPrice struct { func (m *PostedPrice) Reset() { *m = PostedPrice{} } func (*PostedPrice) ProtoMessage() {} func (*PostedPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_188809b7a903b86f, []int{1} + return fileDescriptor_9df40639f5e16f9a, []int{2} } func (m *PostedPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -177,7 +221,7 @@ type CurrentPrice struct { func (m *CurrentPrice) Reset() { *m = CurrentPrice{} } func (*CurrentPrice) ProtoMessage() {} func (*CurrentPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_188809b7a903b86f, []int{2} + return fileDescriptor_9df40639f5e16f9a, []int{3} } func (m *CurrentPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -214,49 +258,117 @@ func (m *CurrentPrice) GetMarketID() string { } func init() { + proto.RegisterType((*Params)(nil), "kava.pricefeed.v1beta1.Params") proto.RegisterType((*Market)(nil), "kava.pricefeed.v1beta1.Market") proto.RegisterType((*PostedPrice)(nil), "kava.pricefeed.v1beta1.PostedPrice") proto.RegisterType((*CurrentPrice)(nil), "kava.pricefeed.v1beta1.CurrentPrice") } func init() { - proto.RegisterFile("kava/pricefeed/v1beta1/pricefeed.proto", fileDescriptor_188809b7a903b86f) + proto.RegisterFile("kava/pricefeed/v1beta1/store.proto", fileDescriptor_9df40639f5e16f9a) } -var fileDescriptor_188809b7a903b86f = []byte{ - // 477 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xf6, 0xa5, 0x69, 0x48, 0x2e, 0x81, 0xc1, 0xa0, 0xca, 0x44, 0xc2, 0x8e, 0x3a, 0x54, 0x41, - 0x28, 0xb6, 0x0a, 0x1b, 0x62, 0x89, 0xc9, 0x40, 0x87, 0x4a, 0x95, 0xc5, 0xc4, 0x12, 0x9d, 0xed, - 0x57, 0x63, 0x25, 0xe6, 0xcc, 0xdd, 0x25, 0x6a, 0xfe, 0x00, 0xf6, 0x8e, 0x8c, 0x8c, 0xec, 0xf0, - 0x47, 0x74, 0xac, 0x98, 0x10, 0x43, 0x28, 0xce, 0xdf, 0xc0, 0xc2, 0x84, 0xee, 0x87, 0x69, 0x47, - 0x22, 0x98, 0xfc, 0xde, 0xf7, 0xbe, 0xf7, 0x9e, 0xbf, 0x4f, 0xef, 0xf0, 0xc1, 0x8c, 0x2c, 0x49, - 0x50, 0xb2, 0x3c, 0x81, 0x53, 0x80, 0x34, 0x58, 0x1e, 0xc6, 0x20, 0xc8, 0xe1, 0x35, 0xe2, 0x97, - 0x8c, 0x0a, 0x6a, 0xef, 0x49, 0x9e, 0x7f, 0x8d, 0x1a, 0x5e, 0xff, 0x7e, 0x42, 0x79, 0x41, 0xf9, - 0x54, 0xb1, 0x02, 0x9d, 0xe8, 0x96, 0xfe, 0xbd, 0x8c, 0x66, 0x54, 0xe3, 0x32, 0x32, 0xa8, 0x97, - 0x51, 0x9a, 0xcd, 0x21, 0x50, 0x59, 0xbc, 0x38, 0x0d, 0x44, 0x5e, 0x00, 0x17, 0xa4, 0x28, 0x35, - 0x61, 0xff, 0x27, 0xc2, 0xad, 0x63, 0xc2, 0x66, 0x20, 0xec, 0x87, 0xb8, 0x53, 0xa8, 0x68, 0x9a, - 0xa7, 0x0e, 0x1a, 0xa0, 0x61, 0x27, 0xec, 0x55, 0x6b, 0xaf, 0xad, 0xcb, 0x47, 0x93, 0xa8, 0xad, - 0xcb, 0x47, 0xa9, 0xfd, 0x00, 0xe3, 0x98, 0x70, 0x98, 0x12, 0xce, 0x41, 0x38, 0x0d, 0xc9, 0x8d, - 0x3a, 0x12, 0x19, 0x4b, 0xc0, 0xf6, 0x70, 0xf7, 0xed, 0x82, 0x8a, 0xba, 0xbe, 0xa3, 0xea, 0x58, - 0x41, 0x9a, 0x10, 0xe3, 0x5b, 0x94, 0x91, 0x64, 0x0e, 0xdc, 0x69, 0x0e, 0x76, 0x86, 0xbd, 0xf0, - 0xc5, 0xaf, 0xb5, 0x37, 0xca, 0x72, 0xf1, 0x7a, 0x11, 0xfb, 0x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f, - 0x5c, 0xeb, 0x72, 0xe3, 0x5a, 0x5f, 0x37, 0xae, 0xf5, 0xea, 0xd1, 0x8d, 0xb1, 0xf2, 0x31, 0x8d, - 0xe6, 0x24, 0xe6, 0x2a, 0x0a, 0xce, 0x6e, 0x3c, 0x40, 0x35, 0x3f, 0x6e, 0x29, 0x0b, 0x9e, 0xfc, - 0x0e, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x80, 0x10, 0xa5, 0x9f, 0x03, 0x00, 0x00, +var fileDescriptor_9df40639f5e16f9a = []byte{ + // 515 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0x25, 0xa9, 0x9b, 0x5c, 0x02, 0x83, 0x41, 0x95, 0x89, 0x84, 0x6d, 0x65, 0x40, 0x46, + 0x28, 0x67, 0xb5, 0x6c, 0x08, 0x21, 0xc5, 0x64, 0xa0, 0x43, 0x51, 0x64, 0x31, 0xb1, 0x44, 0x67, + 0xfb, 0x6a, 0xac, 0xc4, 0x9c, 0xb9, 0xbb, 0x44, 0xcd, 0x0f, 0x60, 0xef, 0xc8, 0xc8, 0xc8, 0x0e, + 0x3f, 0xa2, 0x63, 0xc5, 0x84, 0x18, 0x42, 0x71, 0x7e, 0x03, 0x0b, 0x13, 0xf2, 0xdd, 0xb9, 0xea, + 0xc0, 0x40, 0x45, 0x27, 0xfb, 0x7d, 0xdf, 0xf7, 0xde, 0xbb, 0xf7, 0xdd, 0x3b, 0x38, 0x9c, 0xe3, + 0x15, 0xf6, 0x0b, 0x96, 0xc5, 0xe4, 0x98, 0x90, 0xc4, 0x5f, 0xed, 0x47, 0x44, 0xe0, 0x7d, 0x9f, + 0x0b, 0xca, 0x08, 0x2a, 0x18, 0x15, 0xd4, 0xdc, 0xab, 0x34, 0xe8, 0x52, 0x83, 0xb4, 0x66, 0x70, + 0x2f, 0xa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0x27, 0x57, 0x1e, 0xb3, 0xac, + 0x1f, 0x19, 0xd2, 0x82, 0xc7, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xda, 0xcd, 0xc7, 0x10, 0xeb, + 0x03, 0x00, 0x00, +} + +func (this *Params) VerboseEqual(that interface{}) error { + if that == nil { + if this == nil { + return nil + } + return fmt.Errorf("that == nil && this != nil") + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return fmt.Errorf("that is not of type *Params") + } + } + if that1 == nil { + if this == nil { + return nil + } + return fmt.Errorf("that is type *Params but is nil && this != nil") + } else if this == nil { + return fmt.Errorf("that is type *Params but is not nil && this == nil") + } + if len(this.Markets) != len(that1.Markets) { + return fmt.Errorf("Markets this(%v) Not Equal that(%v)", len(this.Markets), len(that1.Markets)) + } + for i := range this.Markets { + if !this.Markets[i].Equal(&that1.Markets[i]) { + return fmt.Errorf("Markets this[%v](%v) Not Equal that[%v](%v)", i, this.Markets[i], i, that1.Markets[i]) + } + } + return nil } +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Markets) != len(that1.Markets) { + return false + } + for i := range this.Markets { + if !this.Markets[i].Equal(&that1.Markets[i]) { + return false + } + } + return true +} func (this *Market) VerboseEqual(that interface{}) error { if that == nil { if this == nil { @@ -477,6 +589,43 @@ func (this *CurrentPrice) Equal(that interface{}) bool { } return true } +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Markets) > 0 { + for iNdEx := len(m.Markets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Markets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *Market) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -511,7 +660,7 @@ func (m *Market) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.Oracles) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Oracles[iNdEx]) copy(dAtA[i:], m.Oracles[iNdEx]) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.Oracles[iNdEx]))) + i = encodeVarintStore(dAtA, i, uint64(len(m.Oracles[iNdEx]))) i-- dAtA[i] = 0x22 } @@ -519,21 +668,21 @@ func (m *Market) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.QuoteAsset) > 0 { i -= len(m.QuoteAsset) copy(dAtA[i:], m.QuoteAsset) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.QuoteAsset))) + i = encodeVarintStore(dAtA, i, uint64(len(m.QuoteAsset))) i-- dAtA[i] = 0x1a } if len(m.BaseAsset) > 0 { i -= len(m.BaseAsset) copy(dAtA[i:], m.BaseAsset) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.BaseAsset))) + i = encodeVarintStore(dAtA, i, uint64(len(m.BaseAsset))) i-- dAtA[i] = 0x12 } if len(m.MarketID) > 0 { i -= len(m.MarketID) copy(dAtA[i:], m.MarketID) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.MarketID))) + i = encodeVarintStore(dAtA, i, uint64(len(m.MarketID))) i-- dAtA[i] = 0xa } @@ -565,7 +714,7 @@ func (m *PostedPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err1 } i -= n1 - i = encodeVarintPricefeed(dAtA, i, uint64(n1)) + i = encodeVarintStore(dAtA, i, uint64(n1)) i-- dAtA[i] = 0x22 { @@ -574,21 +723,21 @@ func (m *PostedPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i = encodeVarintPricefeed(dAtA, i, uint64(size)) + i = encodeVarintStore(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a if len(m.OracleAddress) > 0 { i -= len(m.OracleAddress) copy(dAtA[i:], m.OracleAddress) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.OracleAddress))) + i = encodeVarintStore(dAtA, i, uint64(len(m.OracleAddress))) i-- dAtA[i] = 0x12 } if len(m.MarketID) > 0 { i -= len(m.MarketID) copy(dAtA[i:], m.MarketID) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.MarketID))) + i = encodeVarintStore(dAtA, i, uint64(len(m.MarketID))) i-- dAtA[i] = 0xa } @@ -621,22 +770,22 @@ func (m *CurrentPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i = encodeVarintPricefeed(dAtA, i, uint64(size)) + i = encodeVarintStore(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 if len(m.MarketID) > 0 { i -= len(m.MarketID) copy(dAtA[i:], m.MarketID) - i = encodeVarintPricefeed(dAtA, i, uint64(len(m.MarketID))) + i = encodeVarintStore(dAtA, i, uint64(len(m.MarketID))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintPricefeed(dAtA []byte, offset int, v uint64) int { - offset -= sovPricefeed(v) +func encodeVarintStore(dAtA []byte, offset int, v uint64) int { + offset -= sovStore(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -646,6 +795,21 @@ func encodeVarintPricefeed(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Markets) > 0 { + for _, e := range m.Markets { + l = e.Size() + n += 1 + l + sovStore(uint64(l)) + } + } + return n +} + func (m *Market) Size() (n int) { if m == nil { return 0 @@ -654,20 +818,20 @@ func (m *Market) Size() (n int) { _ = l l = len(m.MarketID) if l > 0 { - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } l = len(m.BaseAsset) if l > 0 { - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } l = len(m.QuoteAsset) if l > 0 { - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } if len(m.Oracles) > 0 { for _, b := range m.Oracles { l = len(b) - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } } if m.Active { @@ -684,16 +848,16 @@ func (m *PostedPrice) Size() (n int) { _ = l l = len(m.MarketID) if l > 0 { - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } l = len(m.OracleAddress) if l > 0 { - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } l = m.Price.Size() - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiry) - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) return n } @@ -705,18 +869,102 @@ func (m *CurrentPrice) Size() (n int) { _ = l l = len(m.MarketID) if l > 0 { - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) } l = m.Price.Size() - n += 1 + l + sovPricefeed(uint64(l)) + n += 1 + l + sovStore(uint64(l)) return n } -func sovPricefeed(x uint64) (n int) { +func sovStore(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozPricefeed(x uint64) (n int) { - return sovPricefeed(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozStore(x uint64) (n int) { + return sovStore(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowStore + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Markets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Markets = append(m.Markets, Market{}) + if err := m.Markets[len(m.Markets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStore(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStore + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } func (m *Market) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -726,7 +974,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -754,7 +1002,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -768,11 +1016,11 @@ func (m *Market) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -786,7 +1034,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -800,11 +1048,11 @@ func (m *Market) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -818,7 +1066,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -832,11 +1080,11 @@ func (m *Market) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -850,7 +1098,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -863,11 +1111,11 @@ func (m *Market) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -882,7 +1130,7 @@ func (m *Market) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -897,12 +1145,12 @@ func (m *Market) Unmarshal(dAtA []byte) error { m.Active = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipPricefeed(dAtA[iNdEx:]) + skippy, err := skipStore(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -924,7 +1172,7 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -952,7 +1200,7 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -966,11 +1214,11 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -984,7 +1232,7 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -997,11 +1245,11 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -1018,7 +1266,7 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1032,11 +1280,11 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -1052,7 +1300,7 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1065,11 +1313,11 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -1080,12 +1328,12 @@ func (m *PostedPrice) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipPricefeed(dAtA[iNdEx:]) + skippy, err := skipStore(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1107,7 +1355,7 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1135,7 +1383,7 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1149,11 +1397,11 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -1167,7 +1415,7 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPricefeed + return ErrIntOverflowStore } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1181,11 +1429,11 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if postIndex > l { return io.ErrUnexpectedEOF @@ -1196,12 +1444,12 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipPricefeed(dAtA[iNdEx:]) + skippy, err := skipStore(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPricefeed + return ErrInvalidLengthStore } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1215,7 +1463,7 @@ func (m *CurrentPrice) Unmarshal(dAtA []byte) error { } return nil } -func skipPricefeed(dAtA []byte) (n int, err error) { +func skipStore(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -1223,7 +1471,7 @@ func skipPricefeed(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPricefeed + return 0, ErrIntOverflowStore } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1240,7 +1488,7 @@ func skipPricefeed(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPricefeed + return 0, ErrIntOverflowStore } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1256,7 +1504,7 @@ func skipPricefeed(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPricefeed + return 0, ErrIntOverflowStore } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1269,14 +1517,14 @@ func skipPricefeed(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthPricefeed + return 0, ErrInvalidLengthStore } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPricefeed + return 0, ErrUnexpectedEndOfGroupStore } depth-- case 5: @@ -1285,7 +1533,7 @@ func skipPricefeed(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthPricefeed + return 0, ErrInvalidLengthStore } if depth == 0 { return iNdEx, nil @@ -1295,7 +1543,7 @@ func skipPricefeed(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthPricefeed = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPricefeed = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPricefeed = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthStore = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStore = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStore = fmt.Errorf("proto: unexpected end of group") ) From 0d36cd5f167e85441b49507db762d351b3e98a8f Mon Sep 17 00:00:00 2001 From: drklee3 Date: Wed, 10 Nov 2021 09:38:22 -0800 Subject: [PATCH 5/8] Separate response types --- proto/kava/pricefeed/v1beta1/genesis.proto | 4 +- proto/kava/pricefeed/v1beta1/query.proto | 8 +- proto/kava/pricefeed/v1beta1/store.proto | 4 +- proto/kava/pricefeed/v1beta1/tx.proto | 4 +- x/pricefeed/grpc_query.go | 24 +++-- x/pricefeed/grpc_query_test.go | 12 +-- x/pricefeed/keeper/grpc_query.go | 108 -------------------- x/pricefeed/types/market.go | 15 +++ x/pricefeed/types/query.pb.go | 112 +++++++++++---------- 9 files changed, 103 insertions(+), 188 deletions(-) delete mode 100644 x/pricefeed/keeper/grpc_query.go diff --git a/proto/kava/pricefeed/v1beta1/genesis.proto b/proto/kava/pricefeed/v1beta1/genesis.proto index 3e70fc088b..a183595450 100644 --- a/proto/kava/pricefeed/v1beta1/genesis.proto +++ b/proto/kava/pricefeed/v1beta1/genesis.proto @@ -4,8 +4,8 @@ package kava.pricefeed.v1beta1; import "kava/pricefeed/v1beta1/store.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; -option (gogoproto.equal_all) = true; +option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; +option (gogoproto.equal_all) = true; option (gogoproto.verbose_equal_all) = true; // GenesisState defines the pricefeed module's genesis state. diff --git a/proto/kava/pricefeed/v1beta1/query.proto b/proto/kava/pricefeed/v1beta1/query.proto index 03b794e986..0ed693f6ee 100644 --- a/proto/kava/pricefeed/v1beta1/query.proto +++ b/proto/kava/pricefeed/v1beta1/query.proto @@ -6,8 +6,8 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; -option (gogoproto.equal_all) = true; +option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; +option (gogoproto.equal_all) = true; option (gogoproto.verbose_equal_all) = true; // Query defines the gRPC querier service for pricefeed module @@ -122,8 +122,6 @@ message QueryMarketsResponse { // PostedPriceResponse defines a price for market posted by a specific oracle. message PostedPriceResponse { - option (gogoproto.goproto_stringer) = false; - string market_id = 1 [(gogoproto.customname) = "MarketID"]; string oracle_address = 2; string price = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; @@ -133,8 +131,6 @@ message PostedPriceResponse { // CurrentPriceResponse defines a current price for a particular market in the pricefeed // module. message CurrentPriceResponse { - 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]; } diff --git a/proto/kava/pricefeed/v1beta1/store.proto b/proto/kava/pricefeed/v1beta1/store.proto index 89ee4edfee..9bf429137b 100644 --- a/proto/kava/pricefeed/v1beta1/store.proto +++ b/proto/kava/pricefeed/v1beta1/store.proto @@ -5,8 +5,8 @@ import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; -option (gogoproto.equal_all) = true; +option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; +option (gogoproto.equal_all) = true; option (gogoproto.verbose_equal_all) = true; // Params defines the parameters for the pricefeed module. diff --git a/proto/kava/pricefeed/v1beta1/tx.proto b/proto/kava/pricefeed/v1beta1/tx.proto index 69900c6e87..b0d95b5ebb 100644 --- a/proto/kava/pricefeed/v1beta1/tx.proto +++ b/proto/kava/pricefeed/v1beta1/tx.proto @@ -4,8 +4,8 @@ package kava.pricefeed.v1beta1; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; -option (gogoproto.equal_all) = true; +option go_package = "github.com/kava-labs/kava/x/pricefeed/types"; +option (gogoproto.equal_all) = true; option (gogoproto.verbose_equal_all) = true; // Msg defines the pricefeed Msg service. diff --git a/x/pricefeed/grpc_query.go b/x/pricefeed/grpc_query.go index e5cbc209d8..5f243747f9 100644 --- a/x/pricefeed/grpc_query.go +++ b/x/pricefeed/grpc_query.go @@ -49,16 +49,17 @@ func (k QueryServer) Price(c context.Context, req *types.QueryPriceRequest) (*ty } return &types.QueryPriceResponse{ - Price: types.CurrentPrice{ - MarketID: currentPrice.MarketID, - Price: currentPrice.Price, - }}, nil + Price: types.CurrentPriceResponse(currentPrice)}, nil } func (k QueryServer) Prices(c context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error) { ctx := sdk.UnwrapSDKContext(c) - currentPrices := k.keeper.GetCurrentPrices(ctx) + var currentPrices []types.CurrentPriceResponse + + for _, cp := range k.keeper.GetCurrentPrices(ctx) { + currentPrices = append(currentPrices, types.CurrentPriceResponse(cp)) + } return &types.QueryPricesResponse{ Prices: currentPrices, @@ -72,10 +73,19 @@ func (k QueryServer) RawPrices(c context.Context, req *types.QueryRawPricesReque if !found { return nil, status.Error(codes.NotFound, "invalid market ID") } - rawPrices := k.keeper.GetRawPrices(ctx, req.MarketId) + + var prices []types.PostedPriceResponse + for _, rp := range k.keeper.GetRawPrices(ctx, req.MarketId) { + prices = append(prices, types.PostedPriceResponse{ + MarketID: rp.MarketID, + OracleAddress: rp.OracleAddress.String(), + Price: rp.Price, + Expiry: rp.Expiry, + }) + } return &types.QueryRawPricesResponse{ - RawPrices: rawPrices, + RawPrices: prices, }, nil } diff --git a/x/pricefeed/grpc_query_test.go b/x/pricefeed/grpc_query_test.go index 72377bfcd7..56535ac3bb 100644 --- a/x/pricefeed/grpc_query_test.go +++ b/x/pricefeed/grpc_query_test.go @@ -83,7 +83,7 @@ func (suite *grpcQueryTestSuite) TestGrpcPrice() { suite.setTestParams() suite.setTstPrice() - expectedPrice := types.NewCurrentPrice("tstusd", sdk.MustNewDecFromStr("0.34")) + expectedPrice := types.NewCurrentPriceResponse("tstusd", sdk.MustNewDecFromStr("0.34")) res, err := suite.queryServer.Price(sdk.WrapSDKContext(suite.ctx), &types.QueryPriceRequest{MarketId: "tstusd"}) suite.NoError(err) @@ -110,7 +110,7 @@ func (suite *grpcQueryTestSuite) TestGrpcPrices() { suite.setTestParams() suite.setTstPrice() - expectedPrice := types.NewCurrentPrice("tstusd", sdk.MustNewDecFromStr("0.34")) + expectedPrice := types.NewCurrentPriceResponse("tstusd", sdk.MustNewDecFromStr("0.34")) prices, err := suite.queryServer.Prices(sdk.WrapSDKContext(suite.ctx), &types.QueryPricesRequest{}) suite.NoError(err) @@ -129,20 +129,20 @@ func (suite *grpcQueryTestSuite) TestGrpcRawPrices() { suite.ElementsMatch( res.RawPrices, - []types.PostedPrice{ - types.NewPostedPrice( + []types.PostedPriceResponse{ + types.NewPostedPriceResponse( "tstusd", suite.addrs[0], sdk.MustNewDecFromStr("0.33"), suite.now.Add(time.Hour*1), ), - types.NewPostedPrice( + types.NewPostedPriceResponse( "tstusd", suite.addrs[1], sdk.MustNewDecFromStr("0.35"), suite.now.Add(time.Hour*1), ), - types.NewPostedPrice( + types.NewPostedPriceResponse( "tstusd", suite.addrs[2], sdk.MustNewDecFromStr("0.34"), diff --git a/x/pricefeed/keeper/grpc_query.go b/x/pricefeed/keeper/grpc_query.go deleted file mode 100644 index de9f371fa0..0000000000 --- a/x/pricefeed/keeper/grpc_query.go +++ /dev/null @@ -1,108 +0,0 @@ -package keeper - -import ( - "context" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/kava-labs/kava/x/pricefeed/types" -) - -var _ types.QueryServer = Keeper{} - -// Params implements the gRPC service handler for querying x/swap parameters. -func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - if req == nil { - return nil, status.Errorf(codes.InvalidArgument, "empty request") - } - - sdkCtx := sdk.UnwrapSDKContext(c) - params := k.GetParams(sdkCtx) - - return &types.QueryParamsResponse{Params: params}, nil -} - -func (k Keeper) Price(c context.Context, req *types.QueryPriceRequest) (*types.QueryPriceResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - _, found := k.GetMarket(ctx, req.MarketId) - if !found { - return nil, status.Error(codes.InvalidArgument, "invalid market ID") - } - currentPrice, sdkErr := k.GetCurrentPrice(ctx, req.MarketId) - if sdkErr != nil { - return nil, sdkErr - } - - return &types.QueryPriceResponse{ - Price: types.CurrentPriceResponse{ - MarketID: currentPrice.MarketID, - Price: currentPrice.Price, - }}, nil - -} -func (k Keeper) Prices(c context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - var currentPrices []types.CurrentPriceResponse - - for _, cp := range k.GetCurrentPrices(ctx) { - currentPrices = append(currentPrices, types.CurrentPriceResponse{ - MarketID: cp.MarketID, - Price: cp.Price, - }) - } - - return &types.QueryPricesResponse{ - Prices: currentPrices, - }, nil -} - -func (k Keeper) RawPrices(c context.Context, req *types.QueryRawPricesRequest) (*types.QueryRawPricesResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - _, found := k.GetMarket(ctx, req.MarketId) - if !found { - return nil, status.Error(codes.NotFound, "invalid market ID") - } - - var prices []types.PostedPriceResponse - for _, rp := range k.GetRawPrices(ctx, req.MarketId) { - prices = append(prices, types.PostedPriceResponse{ - MarketID: rp.MarketID, - OracleAddress: rp.OracleAddress.String(), - Price: rp.Price, - Expiry: rp.Expiry, - }) - } - - return &types.QueryRawPricesResponse{ - RawPrices: prices, - }, nil -} - -func (k Keeper) Oracles(c context.Context, req *types.QueryOraclesRequest) (*types.QueryOraclesResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - oracles, err := k.GetOracles(ctx, req.MarketId) - if err != nil { - return nil, status.Error(codes.NotFound, "invalid market ID") - } - - return &types.QueryOraclesResponse{ - Oracles: oracles, - }, nil -} - -func (k Keeper) Markets(c context.Context, req *types.QueryMarketsRequest) (*types.QueryMarketsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) - - markets := k.GetMarkets(ctx) - - return &types.QueryMarketsResponse{ - Markets: markets, - }, nil -} diff --git a/x/pricefeed/types/market.go b/x/pricefeed/types/market.go index 47d04ca56b..124efc9a57 100644 --- a/x/pricefeed/types/market.go +++ b/x/pricefeed/types/market.go @@ -76,6 +76,11 @@ func NewCurrentPrice(marketID string, price sdk.Dec) CurrentPrice { return CurrentPrice{MarketID: marketID, Price: price} } +// NewCurrentPriceResponse returns an instance of CurrentPriceResponse +func NewCurrentPriceResponse(marketID string, price sdk.Dec) CurrentPriceResponse { + return CurrentPriceResponse{MarketID: marketID, Price: price} +} + // NewPostedPrice returns a new PostedPrice func NewPostedPrice(marketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPrice { return PostedPrice{ @@ -86,6 +91,16 @@ func NewPostedPrice(marketID string, oracle sdk.AccAddress, price sdk.Dec, expir } } +// NewPostedPrice returns a new PostedPrice +func NewPostedPriceResponse(marketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPriceResponse { + return PostedPriceResponse{ + MarketID: marketID, + OracleAddress: oracle.String(), + Price: price, + Expiry: expiry, + } +} + // Validate performs a basic check of a PostedPrice params. func (pp PostedPrice) Validate() error { if strings.TrimSpace(pp.MarketID) == "" { diff --git a/x/pricefeed/types/query.pb.go b/x/pricefeed/types/query.pb.go index 3ae243fe3c..f3c92e7680 100644 --- a/x/pricefeed/types/query.pb.go +++ b/x/pricefeed/types/query.pb.go @@ -500,8 +500,9 @@ type PostedPriceResponse struct { Expiry time.Time `protobuf:"bytes,4,opt,name=expiry,proto3,stdtime" json:"expiry"` } -func (m *PostedPriceResponse) Reset() { *m = PostedPriceResponse{} } -func (*PostedPriceResponse) ProtoMessage() {} +func (m *PostedPriceResponse) Reset() { *m = PostedPriceResponse{} } +func (m *PostedPriceResponse) String() string { return proto.CompactTextString(m) } +func (*PostedPriceResponse) ProtoMessage() {} func (*PostedPriceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_84567be3085e4c6c, []int{12} } @@ -560,8 +561,9 @@ type CurrentPriceResponse struct { Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` } -func (m *CurrentPriceResponse) Reset() { *m = CurrentPriceResponse{} } -func (*CurrentPriceResponse) ProtoMessage() {} +func (m *CurrentPriceResponse) Reset() { *m = CurrentPriceResponse{} } +func (m *CurrentPriceResponse) String() string { return proto.CompactTextString(m) } +func (*CurrentPriceResponse) ProtoMessage() {} func (*CurrentPriceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_84567be3085e4c6c, []int{13} } @@ -621,57 +623,57 @@ func init() { } var fileDescriptor_84567be3085e4c6c = []byte{ - // 794 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x4f, 0x4f, 0x13, 0x4f, - 0x18, 0xc7, 0x3b, 0x50, 0x5a, 0x3a, 0xbf, 0x3f, 0x89, 0x43, 0x21, 0x4d, 0x35, 0x5b, 0x6c, 0x22, - 0x0a, 0xa5, 0xbb, 0x01, 0x22, 0x31, 0xc4, 0x98, 0x58, 0x39, 0x88, 0x09, 0x11, 0x1b, 0x2f, 0x1a, - 0x13, 0x32, 0xed, 0x0e, 0xb5, 0x81, 0x76, 0x96, 0x99, 0x2d, 0x7f, 0x62, 0xbc, 0x18, 0x0f, 0x7a, - 0x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xec, 0x44, 0x94, 0x54, 0x00, 0x99, 0x56, 0x20, 0x93, 0x64, 0x22, 0x14, 0x44, - 0xbd, 0x47, 0xeb, 0x59, 0xe7, 0x4c, 0x9e, 0xeb, 0x05, 0xa9, 0x30, 0x89, 0x20, 0x15, 0x75, 0x41, - 0x01, 0x47, 0x89, 0xb0, 0x20, 0x0d, 0xf0, 0x11, 0xe1, 0x54, 0xc7, 0x8f, 0x48, 0xf1, 0x54, 0x89, - 0xe3, 0x9e, 0x97, 0x35, 0xa3, 0xa6, 0x03, 0xd4, 0x75, 0x05, 0x65, 0x91, 0x62, 0x18, 0x94, 0xa0, - 0x9b, 0x3d, 0xf6, 0xf5, 0x1e, 0xe1, 0x24, 0xf8, 0x10, 0x39, 0x7d, 0x09, 0x41, 0x9f, 0xcb, 0x4e, - 0x46, 0x4b, 0x06, 0xba, 0x19, 0x45, 0x57, 0x24, 0x85, 0x30, 0x3a, 0x70, 0xba, 0x00, 0xdb, 0x0e, - 0xc2, 0x49, 0x30, 0xb5, 0x33, 0xd8, 0x82, 0x8e, 0x78, 0x06, 0xdb, 0x31, 0x9f, 0xcc, 0x5f, 0x55, - 0x6c, 0x97, 0x49, 0x2e, 0x8c, 0x0d, 0x0c, 0xb1, 0xb4, 0x78, 0xf8, 0xdd, 0x40, 0x9f, 0xda, 0x06, - 0xda, 0x6b, 0x1b, 0x68, 0xbf, 0x6d, 0xa0, 0xc3, 0xb6, 0x81, 0x76, 0x8f, 0x8c, 0xd8, 0xfe, 0x91, - 0x11, 0xfb, 0x72, 0x64, 0xc4, 0x1e, 0x17, 0xba, 0x5e, 0xb7, 0xd7, 0xac, 0xb8, 0x46, 0x2b, 0x52, - 0xb7, 0xdd, 0xea, 0x6a, 0xac, 0x9e, 0x79, 0x25, 0xa1, 0x1c, 0x69, 0xe6, 0x57, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x4a, 0xaa, 0xf0, 0x48, 0x3a, 0x09, 0x00, 0x00, + // 788 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcd, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0x3b, 0xbc, 0xb4, 0x74, 0x7e, 0x2f, 0xc9, 0x6f, 0x28, 0xa4, 0xe9, 0xcf, 0x6c, 0xb1, + 0x89, 0x28, 0x94, 0xee, 0x06, 0x88, 0xc4, 0x10, 0x63, 0x62, 0xe5, 0x20, 0x26, 0x44, 0x6c, 0xbc, + 0x68, 0x4c, 0xc8, 0xb4, 0x3b, 0xd4, 0x06, 0xda, 0x59, 0x66, 0xb6, 0xbc, 0xc4, 0x78, 0x31, 0x26, + 0xea, 0xc1, 0x84, 0xe8, 0xc9, 0x9b, 0xde, 0xfc, 0x53, 0x38, 0x92, 0x78, 0x31, 0x1e, 0x10, 0x8b, + 0x37, 0xff, 0x09, 0xb3, 0x33, 0xcf, 0xae, 0x5d, 0xe8, 0xc2, 0xa2, 0xa7, 0xb6, 0x4f, 0x9f, 0xe7, + 0xf9, 0x7e, 0x9e, 0x67, 0x66, 0xbe, 0xb8, 0xb0, 0x46, 0x37, 0xa9, 0xe5, 0x88, 0x46, 0x8d, 0xad, + 0x32, 0x66, 0x5b, 0x9b, 0xd3, 0x55, 0xe6, 0xd2, 0x69, 0x6b, 0xa3, 0xcd, 0xc4, 0x8e, 0xe9, 0x08, + 0xee, 0x72, 0x32, 0xea, 0xe5, 0x98, 0x41, 0x8e, 0x09, 0x39, 0xb9, 0xa8, 0x5a, 0xe9, 0x72, 0xc1, + 0x74, 0x6d, 0x2e, 0x53, 0xe7, 0x75, 0xae, 0xbe, 0x5a, 0xde, 0x37, 0x88, 0x5e, 0xa8, 0x73, 0x5e, + 0x5f, 0x67, 0x16, 0x75, 0x1a, 0x16, 0x6d, 0xb5, 0xb8, 0x4b, 0xdd, 0x06, 0x6f, 0x49, 0xf8, 0x37, + 0x0f, 0xff, 0xaa, 0x5f, 0xd5, 0xf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8f, 0x1d, 0x03, 0xed, 0x75, 0x0c, 0xb4, 0xdf, + 0x31, 0xd0, 0x61, 0xc7, 0x40, 0xbb, 0x47, 0x46, 0x62, 0xff, 0xc8, 0x48, 0x7c, 0x3e, 0x32, 0x12, + 0x0f, 0x8b, 0x5d, 0xef, 0xda, 0x6b, 0x56, 0x5a, 0xa7, 0x55, 0xa9, 0xdb, 0x6e, 0x77, 0x35, 0x56, + 0x0f, 0xbc, 0x9a, 0x54, 0x2e, 0x34, 0xfb, 0x33, 0x00, 0x00, 0xff, 0xff, 0x84, 0x71, 0x70, 0xff, + 0x2e, 0x09, 0x00, 0x00, } func (this *QueryParamsRequest) VerboseEqual(that interface{}) error { From cf8441e67a1b022e49f8b0e8984eb49f89e77500 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Wed, 10 Nov 2021 09:39:27 -0800 Subject: [PATCH 6/8] Remove invariant todo --- x/pricefeed/module.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/pricefeed/module.go b/x/pricefeed/module.go index d7ef6362ed..ab9e805266 100644 --- a/x/pricefeed/module.go +++ b/x/pricefeed/module.go @@ -110,10 +110,7 @@ func (am AppModule) Name() string { } // RegisterInvariants register module invariants -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - // keeper.RegisterInvariants(ir, am.keeper) - // TODO -} +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // Route module message route name func (am AppModule) Route() sdk.Route { From 0cf33841e8f48dd12c1069202729b33769e3be93 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Wed, 10 Nov 2021 10:36:05 -0800 Subject: [PATCH 7/8] Use slice type aliases, convert to response types --- docs/core/proto-docs.md | 22 +- proto/kava/pricefeed/v1beta1/genesis.proto | 2 +- proto/kava/pricefeed/v1beta1/query.proto | 17 +- proto/kava/pricefeed/v1beta1/store.proto | 5 +- x/pricefeed/grpc_query.go | 12 +- x/pricefeed/grpc_query_test.go | 6 +- x/pricefeed/keeper/keeper.go | 19 +- x/pricefeed/keeper/params.go | 2 +- x/pricefeed/types/genesis.go | 2 +- x/pricefeed/types/genesis.pb.go | 27 +- x/pricefeed/types/market.go | 71 ++- x/pricefeed/types/params.go | 4 +- x/pricefeed/types/query.pb.go | 573 +++++++++++++++++++-- x/pricefeed/types/store.pb.go | 72 +-- 14 files changed, 687 insertions(+), 147 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 00e96131fc..ea0920f78e 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -62,6 +62,7 @@ - [kava/pricefeed/v1beta1/query.proto](#kava/pricefeed/v1beta1/query.proto) - [CurrentPriceResponse](#kava.pricefeed.v1beta1.CurrentPriceResponse) + - [MarketResponse](#kava.pricefeed.v1beta1.MarketResponse) - [PostedPriceResponse](#kava.pricefeed.v1beta1.PostedPriceResponse) - [QueryMarketsRequest](#kava.pricefeed.v1beta1.QueryMarketsRequest) - [QueryMarketsResponse](#kava.pricefeed.v1beta1.QueryMarketsResponse) @@ -805,6 +806,25 @@ module. + + +### MarketResponse +MarketResponse defines an asset in the pricefeed. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `market_id` | [string](#string) | | | +| `base_asset` | [string](#string) | | | +| `quote_asset` | [string](#string) | | | +| `oracles` | [string](#string) | repeated | | +| `active` | [bool](#bool) | | | + + + + + + ### PostedPriceResponse @@ -841,7 +861,7 @@ QueryMarketsResponse is the response type for the Query/Markets RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `markets` | [Market](#kava.pricefeed.v1beta1.Market) | repeated | List of markets | +| `markets` | [MarketResponse](#kava.pricefeed.v1beta1.MarketResponse) | repeated | List of markets | diff --git a/proto/kava/pricefeed/v1beta1/genesis.proto b/proto/kava/pricefeed/v1beta1/genesis.proto index a183595450..3789f0086d 100644 --- a/proto/kava/pricefeed/v1beta1/genesis.proto +++ b/proto/kava/pricefeed/v1beta1/genesis.proto @@ -13,5 +13,5 @@ message GenesisState { // params defines all the paramaters of the module. Params params = 1 [(gogoproto.nullable) = false]; - repeated PostedPrice posted_prices = 2 [(gogoproto.nullable) = false]; + repeated PostedPrice posted_prices = 2 [(gogoproto.castrepeated) = "PostedPrices", (gogoproto.nullable) = false]; } diff --git a/proto/kava/pricefeed/v1beta1/query.proto b/proto/kava/pricefeed/v1beta1/query.proto index 0ed693f6ee..a398f6a944 100644 --- a/proto/kava/pricefeed/v1beta1/query.proto +++ b/proto/kava/pricefeed/v1beta1/query.proto @@ -76,7 +76,8 @@ message QueryPricesRequest {} message QueryPricesResponse { option (gogoproto.goproto_getters) = false; - repeated CurrentPriceResponse prices = 1 [(gogoproto.nullable) = false]; + repeated CurrentPriceResponse prices = 1 + [(gogoproto.castrepeated) = "CurrentPriceResponses", (gogoproto.nullable) = false]; } // QueryRawPricesRequest is the request type for the Query/RawPrices RPC method. @@ -91,7 +92,8 @@ message QueryRawPricesRequest { message QueryRawPricesResponse { option (gogoproto.goproto_getters) = false; - repeated PostedPriceResponse raw_prices = 1 [(gogoproto.nullable) = false]; + repeated PostedPriceResponse raw_prices = 1 + [(gogoproto.castrepeated) = "PostedPriceResponses", (gogoproto.nullable) = false]; } // QueryOraclesRequest is the request type for the Query/Oracles RPC method. @@ -117,7 +119,7 @@ message QueryMarketsResponse { option (gogoproto.goproto_getters) = false; // List of markets - repeated Market markets = 1 [(gogoproto.nullable) = false]; + repeated MarketResponse markets = 1 [(gogoproto.castrepeated) = "MarketResponses", (gogoproto.nullable) = false]; } // PostedPriceResponse defines a price for market posted by a specific oracle. @@ -134,3 +136,12 @@ message CurrentPriceResponse { string market_id = 1 [(gogoproto.customname) = "MarketID"]; string price = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } + +// MarketResponse defines an asset in the pricefeed. +message MarketResponse { + string market_id = 1 [(gogoproto.customname) = "MarketID"]; + string base_asset = 2; + string quote_asset = 3; + repeated string oracles = 4; + bool active = 5; +} diff --git a/proto/kava/pricefeed/v1beta1/store.proto b/proto/kava/pricefeed/v1beta1/store.proto index 9bf429137b..7aa18532de 100644 --- a/proto/kava/pricefeed/v1beta1/store.proto +++ b/proto/kava/pricefeed/v1beta1/store.proto @@ -11,8 +11,9 @@ option (gogoproto.verbose_equal_all) = true; // Params defines the parameters for the pricefeed module. message Params { - option (gogoproto.goproto_stringer) = false; // false here because we define Stringer method in params.go - repeated Market markets = 1 [(gogoproto.nullable) = false]; + option (gogoproto.goproto_stringer) = false; + + repeated Market markets = 1 [(gogoproto.castrepeated) = "Markets", (gogoproto.nullable) = false]; } // Market defines an asset in the pricefeed. diff --git a/x/pricefeed/grpc_query.go b/x/pricefeed/grpc_query.go index 5f243747f9..a830555c41 100644 --- a/x/pricefeed/grpc_query.go +++ b/x/pricefeed/grpc_query.go @@ -36,6 +36,7 @@ func (k QueryServer) Params(c context.Context, req *types.QueryParamsRequest) (* return &types.QueryParamsResponse{Params: params}, nil } +// Price implements the gRPC service handler for querying x/pricefeed price. func (k QueryServer) Price(c context.Context, req *types.QueryPriceRequest) (*types.QueryPriceResponse, error) { ctx := sdk.UnwrapSDKContext(c) @@ -50,12 +51,12 @@ func (k QueryServer) Price(c context.Context, req *types.QueryPriceRequest) (*ty return &types.QueryPriceResponse{ Price: types.CurrentPriceResponse(currentPrice)}, nil - } + func (k QueryServer) Prices(c context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error) { ctx := sdk.UnwrapSDKContext(c) - var currentPrices []types.CurrentPriceResponse + var currentPrices types.CurrentPriceResponses for _, cp := range k.keeper.GetCurrentPrices(ctx) { currentPrices = append(currentPrices, types.CurrentPriceResponse(cp)) @@ -74,7 +75,7 @@ func (k QueryServer) RawPrices(c context.Context, req *types.QueryRawPricesReque return nil, status.Error(codes.NotFound, "invalid market ID") } - var prices []types.PostedPriceResponse + var prices types.PostedPriceResponses for _, rp := range k.keeper.GetRawPrices(ctx, req.MarketId) { prices = append(prices, types.PostedPriceResponse{ MarketID: rp.MarketID, @@ -110,7 +111,10 @@ func (k QueryServer) Oracles(c context.Context, req *types.QueryOraclesRequest) func (k QueryServer) Markets(c context.Context, req *types.QueryMarketsRequest) (*types.QueryMarketsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - markets := k.keeper.GetMarkets(ctx) + var markets types.MarketResponses + for _, market := range k.keeper.GetMarkets(ctx) { + markets = append(markets, market.ToMarketResponse()) + } return &types.QueryMarketsResponse{ Markets: markets, diff --git a/x/pricefeed/grpc_query_test.go b/x/pricefeed/grpc_query_test.go index 56535ac3bb..f21451bba2 100644 --- a/x/pricefeed/grpc_query_test.go +++ b/x/pricefeed/grpc_query_test.go @@ -204,14 +204,16 @@ func (suite *grpcQueryTestSuite) TestGrpcOracles_InvalidMarket() { func (suite *grpcQueryTestSuite) TestGrpcMarkets() { params := types.NewParams([]types.Market{ {MarketID: "tstusd", BaseAsset: "tst", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, + {MarketID: "btcusd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true}, }) suite.keeper.SetParams(suite.ctx, params) res, err := suite.queryServer.Markets(sdk.WrapSDKContext(suite.ctx), &types.QueryMarketsRequest{}) suite.NoError(err) - suite.Len(res.Markets, 1) + suite.Len(res.Markets, 2) suite.Equal(len(res.Markets), len(params.Markets)) - suite.NoError(res.Markets[0].VerboseEqual(params.Markets[0])) + suite.NoError(res.Markets[0].VerboseEqual(params.Markets[0].ToMarketResponse())) + suite.NoError(res.Markets[1].VerboseEqual(params.Markets[1].ToMarketResponse())) } func (suite *grpcQueryTestSuite) setTstPrice() { diff --git a/x/pricefeed/keeper/keeper.go b/x/pricefeed/keeper/keeper.go index 784b8df829..c7e35aea2c 100644 --- a/x/pricefeed/keeper/keeper.go +++ b/x/pricefeed/keeper/keeper.go @@ -109,7 +109,7 @@ func (k Keeper) SetCurrentPrices(ctx sdk.Context, marketID string) error { return types.ErrNoValidPrice } - medianPrice := k.CalculateMedianPrice(ctx, notExpiredPrices) + medianPrice := k.CalculateMedianPrice(notExpiredPrices) // check case that market price was not set in genesis if validPrevPrice && !medianPrice.Equal(prevPrice.Price) { @@ -135,7 +135,7 @@ func (k Keeper) setCurrentPrice(ctx sdk.Context, marketID string, currentPrice t } // CalculateMedianPrice calculates the median prices for the input prices. -func (k Keeper) CalculateMedianPrice(ctx sdk.Context, prices []types.CurrentPrice) sdk.Dec { +func (k Keeper) CalculateMedianPrice(prices []types.CurrentPrice) sdk.Dec { l := len(prices) if l == 1 { @@ -148,16 +148,15 @@ func (k Keeper) CalculateMedianPrice(ctx sdk.Context, prices []types.CurrentPric }) // for even numbers of prices, the median is calculated as the mean of the two middle prices if l%2 == 0 { - median := k.calculateMeanPrice(ctx, prices[l/2-1:l/2+1]) + median := k.calculateMeanPrice(prices[l/2-1], prices[l/2]) return median } // for odd numbers of prices, return the middle element return prices[l/2].Price - } -func (k Keeper) calculateMeanPrice(ctx sdk.Context, prices []types.CurrentPrice) sdk.Dec { - sum := prices[0].Price.Add(prices[1].Price) +func (k Keeper) calculateMeanPrice(priceA, priceB types.CurrentPrice) sdk.Dec { + sum := priceA.Price.Add(priceB.Price) mean := sum.Quo(sdk.NewDec(2)) return mean } @@ -195,8 +194,8 @@ func (k Keeper) IterateCurrentPrices(ctx sdk.Context, cb func(cp types.CurrentPr } // GetCurrentPrices returns all current price objects from the store -func (k Keeper) GetCurrentPrices(ctx sdk.Context) []types.CurrentPrice { - var cps []types.CurrentPrice +func (k Keeper) GetCurrentPrices(ctx sdk.Context) types.CurrentPrices { + var cps types.CurrentPrices k.IterateCurrentPrices(ctx, func(cp types.CurrentPrice) (stop bool) { cps = append(cps, cp) return false @@ -205,8 +204,8 @@ func (k Keeper) GetCurrentPrices(ctx sdk.Context) []types.CurrentPrice { } // GetRawPrices fetches the set of all prices posted by oracles for an asset -func (k Keeper) GetRawPrices(ctx sdk.Context, marketId string) []types.PostedPrice { - var pps []types.PostedPrice +func (k Keeper) GetRawPrices(ctx sdk.Context, marketId string) types.PostedPrices { + var pps types.PostedPrices k.IterateRawPricesByMarket(ctx, marketId, func(pp types.PostedPrice) (stop bool) { pps = append(pps, pp) return false diff --git a/x/pricefeed/keeper/params.go b/x/pricefeed/keeper/params.go index e8d27ca6bb..61b30c4a3f 100644 --- a/x/pricefeed/keeper/params.go +++ b/x/pricefeed/keeper/params.go @@ -20,7 +20,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { } // GetMarkets returns the markets from params -func (k Keeper) GetMarkets(ctx sdk.Context) []types.Market { +func (k Keeper) GetMarkets(ctx sdk.Context) types.Markets { return k.GetParams(ctx).Markets } diff --git a/x/pricefeed/types/genesis.go b/x/pricefeed/types/genesis.go index a43c64e0ed..c9eba7bee8 100644 --- a/x/pricefeed/types/genesis.go +++ b/x/pricefeed/types/genesis.go @@ -23,5 +23,5 @@ func (gs GenesisState) Validate() error { return err } - return ValidatePostedPrices(gs.PostedPrices) + return gs.PostedPrices.Validate() } diff --git a/x/pricefeed/types/genesis.pb.go b/x/pricefeed/types/genesis.pb.go index 06fad99beb..ba10107adb 100644 --- a/x/pricefeed/types/genesis.pb.go +++ b/x/pricefeed/types/genesis.pb.go @@ -26,8 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the pricefeed module's genesis state. type GenesisState struct { // params defines all the paramaters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - PostedPrices []PostedPrice `protobuf:"bytes,2,rep,name=posted_prices,json=postedPrices,proto3" json:"posted_prices"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + PostedPrices PostedPrices `protobuf:"bytes,2,rep,name=posted_prices,json=postedPrices,proto3,castrepeated=PostedPrices" json:"posted_prices"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -70,7 +70,7 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetPostedPrices() []PostedPrice { +func (m *GenesisState) GetPostedPrices() PostedPrices { if m != nil { return m.PostedPrices } @@ -86,23 +86,24 @@ func init() { } var fileDescriptor_fffec798191784d2 = []byte{ - // 252 bytes of a gzipped FileDescriptorProto + // 262 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x4e, 0x2c, 0x4b, 0xd4, 0x2f, 0x28, 0xca, 0x4c, 0x4e, 0x4d, 0x4b, 0x4d, 0x4d, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x03, 0xa9, 0xd2, 0x83, 0xab, 0xd2, 0x83, 0xaa, 0x92, 0x52, 0xc2, 0xa1, 0xbb, 0xb8, 0x24, 0xbf, 0x28, 0x15, 0xa2, 0x57, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, - 0x20, 0xa2, 0x4a, 0x73, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x76, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x0a, + 0x20, 0xa2, 0x4a, 0x6b, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x76, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0xd9, 0x70, 0xb1, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x16, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0xc9, 0xe9, 0x61, 0xb7, 0x53, 0x2f, 0x00, 0xac, 0xca, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, - 0xa8, 0x1e, 0x21, 0x3f, 0x2e, 0xde, 0x82, 0xfc, 0xe2, 0x92, 0xd4, 0x94, 0x78, 0xb0, 0x86, 0x62, - 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x65, 0x9c, 0x86, 0x80, 0x15, 0x07, 0x80, 0xc4, 0xa1, - 0x26, 0xf1, 0x14, 0x20, 0x84, 0x8a, 0x9d, 0x7c, 0x1f, 0x3c, 0x94, 0x63, 0x5c, 0xf1, 0x48, 0x8e, - 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, - 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xb4, 0xd3, 0x33, 0x4b, 0x32, - 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x41, 0x96, 0xe8, 0xe6, 0x24, 0x26, 0x15, 0x83, 0x59, - 0xfa, 0x15, 0x48, 0x21, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0xb4, 0x31, 0x20, - 0x00, 0x00, 0xff, 0xff, 0xcb, 0x8a, 0x8d, 0x8f, 0x6e, 0x01, 0x00, 0x00, + 0xa8, 0x1e, 0xa1, 0x38, 0x2e, 0xde, 0x82, 0xfc, 0xe2, 0x92, 0xd4, 0x94, 0x78, 0xb0, 0x86, 0x62, + 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x65, 0x9c, 0x86, 0x80, 0x15, 0x07, 0x80, 0xc4, 0x9d, + 0x44, 0x40, 0x26, 0xad, 0xba, 0x2f, 0xcf, 0x83, 0x24, 0x58, 0x1c, 0xc4, 0x53, 0x80, 0xc4, 0x73, + 0xf2, 0x7d, 0xf0, 0x50, 0x8e, 0x71, 0xc5, 0x23, 0x39, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, + 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, + 0x07, 0x59, 0xaa, 0x9b, 0x93, 0x98, 0x54, 0x0c, 0x66, 0xe9, 0x57, 0x20, 0x85, 0x50, 0x49, 0x65, + 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x10, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x23, + 0x61, 0x2f, 0x7e, 0x01, 0x00, 0x00, } func (this *GenesisState) VerboseEqual(that interface{}) error { diff --git a/x/pricefeed/types/market.go b/x/pricefeed/types/market.go index 124efc9a57..54dea4ba3f 100644 --- a/x/pricefeed/types/market.go +++ b/x/pricefeed/types/market.go @@ -55,9 +55,17 @@ func (m Market) Validate() error { return nil } -// ValidateMarkets checks if all the markets are valid and there are no -// duplicated entries. -func ValidateMarkets(ms []Market) error { +// ToMarketResponse returns a new MarketResponse from a Market +func (m Market) ToMarketResponse() MarketResponse { + return NewMarketResponse(m.MarketID, m.BaseAsset, m.QuoteAsset, m.Oracles, m.Active) +} + +// Markets is a slice of Market +type Markets []Market + +// Validate checks if all the markets are valid and there are no duplicated +// entries. +func (ms Markets) Validate() error { seenMarkets := make(map[string]bool) for _, m := range ms { if seenMarkets[m.MarketID] { @@ -71,16 +79,41 @@ func ValidateMarkets(ms []Market) error { return nil } +// NewMarketResponse returns a new MarketResponse +func NewMarketResponse(id, base, quote string, oracles []sdk.AccAddress, active bool) MarketResponse { + var strOracles []string + for _, oracle := range oracles { + strOracles = append(strOracles, oracle.String()) + } + + return MarketResponse{ + MarketID: id, + BaseAsset: base, + QuoteAsset: quote, + Oracles: strOracles, + Active: active, + } +} + +// MarketResponses is a slice of MarketResponse +type MarketResponses []MarketResponse + // NewCurrentPrice returns an instance of CurrentPrice func NewCurrentPrice(marketID string, price sdk.Dec) CurrentPrice { return CurrentPrice{MarketID: marketID, Price: price} } +// CurrentPrices is a slice of CurrentPrice +type CurrentPrices []CurrentPrice + // NewCurrentPriceResponse returns an instance of CurrentPriceResponse func NewCurrentPriceResponse(marketID string, price sdk.Dec) CurrentPriceResponse { return CurrentPriceResponse{MarketID: marketID, Price: price} } +// CurrentPriceResponses is a slice of CurrentPriceResponse +type CurrentPriceResponses []CurrentPriceResponse + // NewPostedPrice returns a new PostedPrice func NewPostedPrice(marketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPrice { return PostedPrice{ @@ -91,16 +124,6 @@ func NewPostedPrice(marketID string, oracle sdk.AccAddress, price sdk.Dec, expir } } -// NewPostedPrice returns a new PostedPrice -func NewPostedPriceResponse(marketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPriceResponse { - return PostedPriceResponse{ - MarketID: marketID, - OracleAddress: oracle.String(), - Price: price, - Expiry: expiry, - } -} - // Validate performs a basic check of a PostedPrice params. func (pp PostedPrice) Validate() error { if strings.TrimSpace(pp.MarketID) == "" { @@ -118,9 +141,12 @@ func (pp PostedPrice) Validate() error { return nil } -// ValidatePostedPrices checks if all the posted prices are valid and there are -// no duplicated entries. -func ValidatePostedPrices(pps []PostedPrice) error { +// PostedPrices is a slice of PostedPrice +type PostedPrices []PostedPrice + +// Validate checks if all the posted prices are valid and there are no +// duplicated entries. +func (pps PostedPrices) Validate() error { seenPrices := make(map[string]bool) for _, pp := range pps { if !pp.OracleAddress.Empty() && seenPrices[pp.MarketID+pp.OracleAddress.String()] { @@ -136,6 +162,19 @@ func ValidatePostedPrices(pps []PostedPrice) error { return nil } +// NewPostedPrice returns a new PostedPrice +func NewPostedPriceResponse(marketID string, oracle sdk.AccAddress, price sdk.Dec, expiry time.Time) PostedPriceResponse { + return PostedPriceResponse{ + MarketID: marketID, + OracleAddress: oracle.String(), + Price: price, + Expiry: expiry, + } +} + +// 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 diff --git a/x/pricefeed/types/params.go b/x/pricefeed/types/params.go index ed718338a1..199c7a7aa6 100644 --- a/x/pricefeed/types/params.go +++ b/x/pricefeed/types/params.go @@ -53,10 +53,10 @@ func (p Params) Validate() error { } func validateMarketParams(i interface{}) error { - markets, ok := i.([]Market) + markets, ok := i.(Markets) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - return ValidateMarkets(markets) + return markets.Validate() } diff --git a/x/pricefeed/types/query.pb.go b/x/pricefeed/types/query.pb.go index f3c92e7680..a59fe0df5a 100644 --- a/x/pricefeed/types/query.pb.go +++ b/x/pricefeed/types/query.pb.go @@ -226,7 +226,7 @@ var xxx_messageInfo_QueryPricesRequest proto.InternalMessageInfo // QueryPricesResponse is the response type for the Query/Prices RPC method. type QueryPricesResponse struct { - Prices []CurrentPriceResponse `protobuf:"bytes,1,rep,name=prices,proto3" json:"prices"` + Prices CurrentPriceResponses `protobuf:"bytes,1,rep,name=prices,proto3,castrepeated=CurrentPriceResponses" json:"prices"` } func (m *QueryPricesResponse) Reset() { *m = QueryPricesResponse{} } @@ -303,7 +303,7 @@ var xxx_messageInfo_QueryRawPricesRequest proto.InternalMessageInfo // QueryRawPricesResponse is the response type for the Query/RawPrices RPC // method. type QueryRawPricesResponse struct { - RawPrices []PostedPriceResponse `protobuf:"bytes,1,rep,name=raw_prices,json=rawPrices,proto3" json:"raw_prices"` + RawPrices PostedPriceResponses `protobuf:"bytes,1,rep,name=raw_prices,json=rawPrices,proto3,castrepeated=PostedPriceResponses" json:"raw_prices"` } func (m *QueryRawPricesResponse) Reset() { *m = QueryRawPricesResponse{} } @@ -456,7 +456,7 @@ var xxx_messageInfo_QueryMarketsRequest proto.InternalMessageInfo // QueryMarketsResponse is the response type for the Query/Markets RPC method. type QueryMarketsResponse struct { // List of markets - Markets []Market `protobuf:"bytes,1,rep,name=markets,proto3" json:"markets"` + Markets MarketResponses `protobuf:"bytes,1,rep,name=markets,proto3,castrepeated=MarketResponses" json:"markets"` } func (m *QueryMarketsResponse) Reset() { *m = QueryMarketsResponse{} } @@ -601,6 +601,83 @@ func (m *CurrentPriceResponse) GetMarketID() string { return "" } +// MarketResponse defines an asset in the pricefeed. +type MarketResponse struct { + MarketID string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + BaseAsset string `protobuf:"bytes,2,opt,name=base_asset,json=baseAsset,proto3" json:"base_asset,omitempty"` + QuoteAsset string `protobuf:"bytes,3,opt,name=quote_asset,json=quoteAsset,proto3" json:"quote_asset,omitempty"` + Oracles []string `protobuf:"bytes,4,rep,name=oracles,proto3" json:"oracles,omitempty"` + Active bool `protobuf:"varint,5,opt,name=active,proto3" json:"active,omitempty"` +} + +func (m *MarketResponse) Reset() { *m = MarketResponse{} } +func (m *MarketResponse) String() string { return proto.CompactTextString(m) } +func (*MarketResponse) ProtoMessage() {} +func (*MarketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_84567be3085e4c6c, []int{14} +} +func (m *MarketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MarketResponse.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 *MarketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MarketResponse.Merge(m, src) +} +func (m *MarketResponse) XXX_Size() int { + return m.Size() +} +func (m *MarketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MarketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MarketResponse proto.InternalMessageInfo + +func (m *MarketResponse) GetMarketID() string { + if m != nil { + return m.MarketID + } + return "" +} + +func (m *MarketResponse) GetBaseAsset() string { + if m != nil { + return m.BaseAsset + } + return "" +} + +func (m *MarketResponse) GetQuoteAsset() string { + if m != nil { + return m.QuoteAsset + } + return "" +} + +func (m *MarketResponse) GetOracles() []string { + if m != nil { + return m.Oracles + } + return nil +} + +func (m *MarketResponse) GetActive() bool { + if m != nil { + return m.Active + } + return false +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "kava.pricefeed.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "kava.pricefeed.v1beta1.QueryParamsResponse") @@ -616,6 +693,7 @@ func init() { proto.RegisterType((*QueryMarketsResponse)(nil), "kava.pricefeed.v1beta1.QueryMarketsResponse") proto.RegisterType((*PostedPriceResponse)(nil), "kava.pricefeed.v1beta1.PostedPriceResponse") proto.RegisterType((*CurrentPriceResponse)(nil), "kava.pricefeed.v1beta1.CurrentPriceResponse") + proto.RegisterType((*MarketResponse)(nil), "kava.pricefeed.v1beta1.MarketResponse") } func init() { @@ -623,57 +701,63 @@ func init() { } var fileDescriptor_84567be3085e4c6c = []byte{ - // 788 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcd, 0x4f, 0x13, 0x4f, - 0x18, 0xc7, 0x3b, 0xbc, 0xb4, 0x74, 0x7e, 0x2f, 0xc9, 0x6f, 0x28, 0xa4, 0xe9, 0xcf, 0x6c, 0xb1, - 0x89, 0x28, 0x94, 0xee, 0x06, 0x88, 0xc4, 0x10, 0x63, 0x62, 0xe5, 0x20, 0x26, 0x44, 0x6c, 0xbc, - 0x68, 0x4c, 0xc8, 0xb4, 0x3b, 0xd4, 0x06, 0xda, 0x59, 0x66, 0xb6, 0xbc, 0xc4, 0x78, 0x31, 0x26, - 0xea, 0xc1, 0x84, 0xe8, 0xc9, 0x9b, 0xde, 0xfc, 0x53, 0x38, 0x92, 0x78, 0x31, 0x1e, 0x10, 0x8b, - 0x37, 0xff, 0x09, 0xb3, 0x33, 0xcf, 0xae, 0x5d, 0xe8, 0xc2, 0xa2, 0xa7, 0xb6, 0x4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0x90, - 0x06, 0xf8, 0x80, 0x70, 0x3a, 0xf0, 0x20, 0x52, 0x3a, 0x55, 0xe2, 0xb8, 0xcf, 0xe5, 0xcc, 0xb8, - 0xe9, 0x00, 0x75, 0x55, 0x41, 0x59, 0xa4, 0x14, 0x05, 0x25, 0xe8, 0x56, 0x8f, 0x7d, 0xbd, 0x43, - 0x38, 0x05, 0xde, 0x43, 0x4e, 0x5f, 0x42, 0xd8, 0xdb, 0x72, 0x53, 0xf1, 0x92, 0x81, 0x6e, 0x56, - 0xd1, 0x95, 0x48, 0x31, 0x8a, 0x0e, 0xdc, 0x2d, 0xc4, 0xf6, 0x1a, 0xe1, 0x14, 0x18, 0xd9, 0x19, - 0x6c, 0x61, 0x17, 0x3c, 0x83, 0xed, 0x98, 0x37, 0x16, 0x2e, 0x2b, 0xb6, 0x8b, 0x24, 0x1f, 0xc5, - 0x06, 0x26, 0x58, 0x5e, 0x3a, 0xfc, 0x66, 0xa0, 0x8f, 0x1d, 0x03, 0xed, 0x75, 0x0c, 0xb4, 0xdf, - 0x31, 0xd0, 0x61, 0xc7, 0x40, 0xbb, 0x47, 0x46, 0x62, 0xff, 0xc8, 0x48, 0x7c, 0x3e, 0x32, 0x12, - 0x0f, 0x8b, 0x5d, 0xef, 0xda, 0x6b, 0x56, 0x5a, 0xa7, 0x55, 0xa9, 0xdb, 0x6e, 0x77, 0x35, 0x56, - 0x0f, 0xbc, 0x9a, 0x54, 0x2e, 0x34, 0xfb, 0x33, 0x00, 0x00, 0xff, 0xff, 0x84, 0x71, 0x70, 0xff, - 0x2e, 0x09, 0x00, 0x00, + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xa4, 0xfe, 0x39, 0x85, 0x22, 0xa6, 0x4e, 0xb0, 0x4c, 0xbb, 0x1b, 0x56, 0x22, 0xb4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 0x91, + 0x71, 0x93, 0x39, 0x96, 0xfe, 0xc7, 0x1c, 0xd6, 0x6f, 0x08, 0xdf, 0x48, 0x1f, 0xcd, 0x22, 0x1c, + 0x6e, 0x63, 0xdc, 0xa3, 0x82, 0x75, 0xa9, 0x10, 0x4c, 0x82, 0xdc, 0xb5, 0x28, 0xf2, 0x28, 0x0a, + 0x10, 0x13, 0x5f, 0xdf, 0x1d, 0x73, 0x19, 0xef, 0x2b, 0xc1, 0x5d, 0xac, 0x42, 0x3a, 0x61, 0xe6, + 0x96, 0x16, 0x53, 0xb7, 0x94, 0xac, 0xe0, 0x32, 0xed, 0x4b, 0x7f, 0x8f, 0x35, 0x4a, 0xab, 0xe8, + 0x4e, 0xd5, 0x85, 0xd5, 0xe6, 0xd7, 0x15, 0x5c, 0x52, 0x37, 0x94, 0x7c, 0x8b, 0x70, 0x59, 0x1b, + 0x2a, 0x59, 0xcf, 0xba, 0x8c, 0x17, 0x3d, 0xbc, 0xd9, 0xca, 0x95, 0xab, 0xa5, 0xb0, 0xd6, 0xbe, + 0xfa, 0xfd, 0xef, 0x1f, 0x96, 0x56, 0x89, 0xe1, 0x64, 0xfc, 0x11, 0x69, 0x0f, 0x27, 0xdf, 0x23, + 0x5c, 0x52, 0x07, 0x49, 0xee, 0x5e, 0x0e, 0x3f, 0xe3, 0xee, 0xcd, 0xf5, 0x3c, 0xa9, 0x40, 0x64, + 0x53, 0x11, 0xd9, 0x20, 0xeb, 0x99, 0x44, 0x94, 0x9d, 0x38, 0x9f, 0x27, 0x27, 0xf7, 0x85, 0x16, + 0x48, 0x85, 0x49, 0x8e, 0x56, 0x79, 0x05, 0x4a, 0x19, 0x65, 0x0e, 0x81, 0x34, 0x81, 0x9f, 0x11, + 0xae, 0x25, 0x36, 0x4b, 0xda, 0x97, 0xb6, 0x38, 0xef, 0xe5, 0x4d, 0x3b, 0x6f, 0x3a, 0x90, 0x7a, + 0x57, 0x91, 0x72, 0x48, 0x3b, 0x8b, 0x54, 0x48, 0x27, 0x73, 0xf4, 0xfa, 0x11, 0xe1, 0x0a, 0xd8, + 0x28, 0xb9, 0x5c, 0x84, 0xb4, 0x4d, 0x37, 0x37, 0xf2, 0x25, 0x03, 0xbb, 0xfb, 0x8a, 0x5d, 0x9b, + 0xb4, 0xb2, 0xd8, 0xc1, 0x13, 0x48, 0x71, 0xfb, 0x0e, 0xe1, 0x0a, 0x78, 0xf2, 0x15, 0xdc, 0xd2, + 0x86, 0x7e, 0x05, 0xb7, 0x73, 0x36, 0x6f, 0xbd, 0xa3, 0xb8, 0xbd, 0x45, 0xcc, 0x2c, 0x6e, 0x60, + 0xda, 0x9d, 0x27, 0xa7, 0x7f, 0x19, 0xe8, 0x97, 0xa9, 0x81, 0x0e, 0xa7, 0x06, 0x3a, 0x9a, 0x1a, + 0xe8, 0x74, 0x6a, 0xa0, 0x83, 0x33, 0xa3, 0x70, 0x74, 0x66, 0x14, 0xfe, 0x38, 0x33, 0x0a, 0x9f, + 0xb5, 0x66, 0x7c, 0x28, 0x02, 0x6b, 0xef, 0xd0, 0x9e, 0xd0, 0xb0, 0x2f, 0x66, 0x80, 0x95, 0x21, + 0xf5, 0xca, 0xca, 0x35, 0xef, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xfb, 0x14, 0x01, 0xd9, 0x2c, + 0x0a, 0x00, 0x00, } func (this *QueryParamsRequest) VerboseEqual(that interface{}) error { @@ -1478,6 +1562,94 @@ func (this *CurrentPriceResponse) Equal(that interface{}) bool { } return true } +func (this *MarketResponse) VerboseEqual(that interface{}) error { + if that == nil { + if this == nil { + return nil + } + return fmt.Errorf("that == nil && this != nil") + } + + that1, ok := that.(*MarketResponse) + if !ok { + that2, ok := that.(MarketResponse) + if ok { + that1 = &that2 + } else { + return fmt.Errorf("that is not of type *MarketResponse") + } + } + if that1 == nil { + if this == nil { + return nil + } + return fmt.Errorf("that is type *MarketResponse but is nil && this != nil") + } else if this == nil { + return fmt.Errorf("that is type *MarketResponse but is not nil && this == nil") + } + if this.MarketID != that1.MarketID { + return fmt.Errorf("MarketID this(%v) Not Equal that(%v)", this.MarketID, that1.MarketID) + } + if this.BaseAsset != that1.BaseAsset { + return fmt.Errorf("BaseAsset this(%v) Not Equal that(%v)", this.BaseAsset, that1.BaseAsset) + } + if this.QuoteAsset != that1.QuoteAsset { + return fmt.Errorf("QuoteAsset this(%v) Not Equal that(%v)", this.QuoteAsset, that1.QuoteAsset) + } + if len(this.Oracles) != len(that1.Oracles) { + return fmt.Errorf("Oracles this(%v) Not Equal that(%v)", len(this.Oracles), len(that1.Oracles)) + } + for i := range this.Oracles { + if this.Oracles[i] != that1.Oracles[i] { + return fmt.Errorf("Oracles this[%v](%v) Not Equal that[%v](%v)", i, this.Oracles[i], i, that1.Oracles[i]) + } + } + if this.Active != that1.Active { + return fmt.Errorf("Active this(%v) Not Equal that(%v)", this.Active, that1.Active) + } + return nil +} +func (this *MarketResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MarketResponse) + if !ok { + that2, ok := that.(MarketResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.MarketID != that1.MarketID { + return false + } + if this.BaseAsset != that1.BaseAsset { + return false + } + if this.QuoteAsset != that1.QuoteAsset { + return false + } + if len(this.Oracles) != len(that1.Oracles) { + return false + } + for i := range this.Oracles { + if this.Oracles[i] != that1.Oracles[i] { + return false + } + } + if this.Active != that1.Active { + return false + } + return true +} // Reference imports to suppress errors if they are not otherwise used. var _ context.Context @@ -2214,6 +2386,69 @@ func (m *CurrentPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MarketResponse) 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 *MarketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MarketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Active { + i-- + if m.Active { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if len(m.Oracles) > 0 { + for iNdEx := len(m.Oracles) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Oracles[iNdEx]) + copy(dAtA[i:], m.Oracles[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Oracles[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.QuoteAsset) > 0 { + i -= len(m.QuoteAsset) + copy(dAtA[i:], m.QuoteAsset) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteAsset))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseAsset) > 0 { + i -= len(m.BaseAsset) + copy(dAtA[i:], m.BaseAsset) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseAsset))) + i-- + dAtA[i] = 0x12 + } + if len(m.MarketID) > 0 { + i -= len(m.MarketID) + copy(dAtA[i:], m.MarketID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MarketID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2409,6 +2644,36 @@ func (m *CurrentPriceResponse) Size() (n int) { return n } +func (m *MarketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MarketID) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.BaseAsset) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteAsset) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.Oracles) > 0 { + for _, s := range m.Oracles { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Active { + n += 2 + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3285,7 +3550,7 @@ func (m *QueryMarketsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Markets = append(m.Markets, Market{}) + m.Markets = append(m.Markets, MarketResponse{}) if err := m.Markets[len(m.Markets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3608,6 +3873,204 @@ func (m *CurrentPriceResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MarketResponse) 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 ErrIntOverflowQuery + } + 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: MarketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MarketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseAsset", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseAsset = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteAsset", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QuoteAsset = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Oracles", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Oracles = append(m.Oracles, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Active = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/pricefeed/types/store.pb.go b/x/pricefeed/types/store.pb.go index 8e783f5dc6..7b65b2b6a6 100644 --- a/x/pricefeed/types/store.pb.go +++ b/x/pricefeed/types/store.pb.go @@ -32,7 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the pricefeed module. type Params struct { - Markets []Market `protobuf:"bytes,1,rep,name=markets,proto3" json:"markets"` + Markets Markets `protobuf:"bytes,1,rep,name=markets,proto3,castrepeated=Markets" json:"markets"` } func (m *Params) Reset() { *m = Params{} } @@ -67,7 +67,7 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetMarkets() []Market { +func (m *Params) GetMarkets() Markets { if m != nil { return m.Markets } @@ -269,40 +269,40 @@ func init() { } var fileDescriptor_9df40639f5e16f9a = []byte{ - // 515 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xce, 0x25, 0xa9, 0x9b, 0x5c, 0x02, 0x83, 0x41, 0x95, 0x89, 0x84, 0x6d, 0x65, 0x40, 0x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64, 0xf3, 0x29, 0x34, 0xc8, 0x49, - 0x91, 0xb1, 0xb5, 0xd5, 0x76, 0x81, 0xd7, 0x3b, 0x18, 0x20, 0xb5, 0x6b, 0xa8, 0xde, 0x35, 0xf4, - 0xaa, 0xde, 0xb5, 0xa0, 0x53, 0xb5, 0x38, 0xfd, 0xe1, 0x80, 0x50, 0xe7, 0x68, 0xd7, 0xde, 0x03, - 0xd8, 0x7f, 0xbe, 0x64, 0x8c, 0xbc, 0x15, 0xd7, 0xb6, 0xed, 0x72, 0x8a, 0xe6, 0x7f, 0x4c, 0xa1, - 0xce, 0x11, 0x1c, 0x5d, 0xfc, 0xb4, 0xc1, 0xa7, 0xd2, 0x06, 0x67, 0xa5, 0x0d, 0xce, 0x4b, 0x1b, - 0x5c, 0x94, 0x36, 0x38, 0xdd, 0xda, 0x8d, 0xf3, 0xad, 0xdd, 0xf8, 0xb6, 0xb5, 0x1b, 0xaf, 0x1f, - 0x5d, 0x29, 0x5b, 0x3d, 0x8b, 0xd1, 0x02, 0x47, 0x5c, 0xfe, 0xf9, 0x27, 0x57, 0x1e, 0xb3, 0xac, - 0x1f, 0x19, 0xd2, 0x82, 0xc7, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xda, 0xcd, 0xc7, 0x10, 0xeb, - 0x03, 0x00, 0x00, + // 524 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x3f, 0x8f, 0xd3, 0x4e, + 0x10, 0xcd, 0x26, 0xb9, 0xfc, 0xd9, 0xe4, 0xf7, 0x43, 0x32, 0xe8, 0x64, 0x22, 0x61, 0x5b, 0x29, + 0x90, 0x11, 0xca, 0x5a, 0x77, 0x74, 0x88, 0x26, 0x26, 0x05, 0x29, 0x4e, 0x8a, 0x2c, 0x1a, 0x68, + 0xa2, 0xb5, 0xbd, 0x67, 0xac, 0xc4, 0xac, 0xd9, 0xdd, 0x44, 0x97, 0x0f, 0x40, 0x7f, 0x25, 0x25, + 0x25, 0xa2, 0x85, 0x0f, 0x71, 0xe5, 0x89, 0x0a, 0x51, 0xe4, 0x0e, 0xe7, 0x33, 0xd0, 0x50, 0x21, + 0xef, 0xae, 0x4f, 0x57, 0x50, 0x70, 0x82, 0xca, 0x9e, 0xf7, 0xde, 0xcc, 0xec, 0xbc, 0x9d, 0x85, + 0xc3, 0x05, 0x5e, 0x63, 0x2f, 0x67, 0x69, 0x44, 0x8e, 0x09, 0x89, 0xbd, 0xf5, 0x41, 0x48, 0x04, + 0x3e, 0xf0, 0xb8, 0xa0, 0x8c, 0xa0, 0x9c, 0x51, 0x41, 0x8d, 0xfd, 0x52, 0x83, 0xae, 0x34, 0x48, + 0x6b, 0x06, 0x77, 0x23, 0xca, 0x33, 0xca, 0xe7, 0x52, 0xe5, 0xa9, 0x40, 0xa5, 0x0c, 0xee, 0x24, + 0x34, 0xa1, 0x0a, 0x2f, 0xff, 0x34, 0x6a, 0x27, 0x94, 0x26, 0x4b, 0xe2, 0xc9, 0x28, 0x5c, 0x1d, + 0x7b, 0x22, 0xcd, 0x08, 0x17, 0x38, 0xcb, 0x95, 0x60, 0xf8, 0x02, 0xb6, 0x66, 0x98, 0xe1, 0x8c, + 0x1b, 0x53, 0xd8, 0xce, 0x30, 0x5b, 0x10, 0xc1, 0x4d, 0xe0, 0x34, 0xdc, 0xde, 0xa1, 0x85, 0x7e, + 0x7f, 0x0a, 0x74, 0x24, 0x65, 0xfe, 0xad, 0xb3, 0xad, 0x5d, 0xfb, 0x78, 0x61, 0xb7, 0x55, 0xcc, + 0x83, 0x2a, 0xff, 0x71, 0xf3, 0xdd, 0x7b, 0xbb, 0x36, 0xfc, 0x01, 0x60, 0x4b, 0x51, 0xc6, 0x03, + 0xd8, 0x55, 0xdc, 0x3c, 0x8d, 0x4d, 0xe0, 0x00, 0xb7, 0xeb, 0xf7, 0x8b, 0xad, 0xdd, 0x51, 0xf4, + 0x74, 0x12, 0x74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0x9e, 0x57, 0x6b, 0xe7, 0x77, 0xca, 0x16, 0xa7, + 0x17, 0x36, 0x08, 0x74, 0x8e, 0x76, 0xed, 0x2d, 0x80, 0xfd, 0xa7, 0x2b, 0xc6, 0xc8, 0x6b, 0x71, + 0x63, 0xdb, 0xae, 0xa6, 0xa8, 0xff, 0xc5, 0x14, 0xea, 0x1c, 0xfe, 0xd1, 0xe5, 0x77, 0x0b, 0x7c, + 0x28, 0x2c, 0x70, 0x56, 0x58, 0xe0, 0xbc, 0xb0, 0xc0, 0x65, 0x61, 0x81, 0xd3, 0x9d, 0x55, 0x3b, + 0xdf, 0x59, 0xb5, 0xaf, 0x3b, 0xab, 0xf6, 0xf2, 0xe1, 0xb5, 0xb2, 0xe5, 0x0b, 0x19, 0x2d, 0x71, + 0xc8, 0xe5, 0x9f, 0x77, 0x72, 0xed, 0x5d, 0xcb, 0xfa, 0x61, 0x4b, 0x5a, 0xf0, 0xe8, 0x57, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x79, 0x54, 0x17, 0x7a, 0xf6, 0x03, 0x00, 0x00, } func (this *Params) VerboseEqual(that interface{}) error { From 390c372ca7db3029f18f03266d3bd9cec8489434 Mon Sep 17 00:00:00 2001 From: drklee3 Date: Wed, 10 Nov 2021 11:42:35 -0800 Subject: [PATCH 8/8] Use proto generated stringer methods --- proto/kava/pricefeed/v1beta1/store.proto | 8 --- x/pricefeed/grpc_query.go | 1 - x/pricefeed/types/market.go | 25 ------- x/pricefeed/types/params.go | 10 --- x/pricefeed/types/store.pb.go | 87 ++++++++++++------------ 5 files changed, 45 insertions(+), 86 deletions(-) diff --git a/proto/kava/pricefeed/v1beta1/store.proto b/proto/kava/pricefeed/v1beta1/store.proto index 7aa18532de..3f71782b6b 100644 --- a/proto/kava/pricefeed/v1beta1/store.proto +++ b/proto/kava/pricefeed/v1beta1/store.proto @@ -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; @@ -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", @@ -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]; } diff --git a/x/pricefeed/grpc_query.go b/x/pricefeed/grpc_query.go index a830555c41..d9df828781 100644 --- a/x/pricefeed/grpc_query.go +++ b/x/pricefeed/grpc_query.go @@ -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)) } diff --git a/x/pricefeed/types/market.go b/x/pricefeed/types/market.go index 54dea4ba3f..923260fa39 100644 --- a/x/pricefeed/types/market.go +++ b/x/pricefeed/types/market.go @@ -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) == "" { @@ -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 diff --git a/x/pricefeed/types/params.go b/x/pricefeed/types/params.go index 199c7a7aa6..96716df248 100644 --- a/x/pricefeed/types/params.go +++ b/x/pricefeed/types/params.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "strings" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -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) diff --git a/x/pricefeed/types/store.pb.go b/x/pricefeed/types/store.pb.go index 7b65b2b6a6..654c7e048e 100644 --- a/x/pricefeed/types/store.pb.go +++ b/x/pricefeed/types/store.pb.go @@ -35,8 +35,9 @@ type Params struct { Markets Markets `protobuf:"bytes,1,rep,name=markets,proto3,castrepeated=Markets" json:"markets"` } -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_9df40639f5e16f9a, []int{0} } @@ -83,8 +84,9 @@ type Market struct { Active bool `protobuf:"varint,5,opt,name=active,proto3" json:"active,omitempty"` } -func (m *Market) Reset() { *m = Market{} } -func (*Market) ProtoMessage() {} +func (m *Market) Reset() { *m = Market{} } +func (m *Market) String() string { return proto.CompactTextString(m) } +func (*Market) ProtoMessage() {} func (*Market) Descriptor() ([]byte, []int) { return fileDescriptor_9df40639f5e16f9a, []int{1} } @@ -158,8 +160,9 @@ type PostedPrice struct { Expiry time.Time `protobuf:"bytes,4,opt,name=expiry,proto3,stdtime" json:"expiry"` } -func (m *PostedPrice) Reset() { *m = PostedPrice{} } -func (*PostedPrice) ProtoMessage() {} +func (m *PostedPrice) Reset() { *m = PostedPrice{} } +func (m *PostedPrice) String() string { return proto.CompactTextString(m) } +func (*PostedPrice) ProtoMessage() {} func (*PostedPrice) Descriptor() ([]byte, []int) { return fileDescriptor_9df40639f5e16f9a, []int{2} } @@ -218,8 +221,9 @@ type CurrentPrice struct { Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` } -func (m *CurrentPrice) Reset() { *m = CurrentPrice{} } -func (*CurrentPrice) ProtoMessage() {} +func (m *CurrentPrice) Reset() { *m = CurrentPrice{} } +func (m *CurrentPrice) String() string { return proto.CompactTextString(m) } +func (*CurrentPrice) ProtoMessage() {} func (*CurrentPrice) Descriptor() ([]byte, []int) { return fileDescriptor_9df40639f5e16f9a, []int{3} } @@ -269,40 +273,39 @@ func init() { } var fileDescriptor_9df40639f5e16f9a = []byte{ - // 524 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x3f, 0x8f, 0xd3, 0x4e, - 0x10, 0xcd, 0x26, 0xb9, 0xfc, 0xd9, 0xe4, 0xf7, 0x43, 0x32, 0xe8, 0x64, 0x22, 0x61, 0x5b, 0x29, - 0x90, 0x11, 0xca, 0x5a, 0x77, 0x74, 0x88, 0x26, 0x26, 0x05, 0x29, 0x4e, 0x8a, 0x2c, 0x1a, 0x68, - 0xa2, 0xb5, 0xbd, 0x67, 0xac, 0xc4, 0xac, 0xd9, 0xdd, 0x44, 0x97, 0x0f, 0x40, 0x7f, 0x25, 0x25, - 0x25, 0xa2, 0x85, 0x0f, 0x71, 0xe5, 0x89, 0x0a, 0x51, 0xe4, 0x0e, 0xe7, 0x33, 0xd0, 0x50, 0x21, - 0xef, 0xae, 0x4f, 0x57, 0x50, 0x70, 0x82, 0xca, 0x9e, 0xf7, 0xde, 0xcc, 0xec, 0xbc, 0x9d, 0x85, - 0xc3, 0x05, 0x5e, 0x63, 0x2f, 0x67, 0x69, 0x44, 0x8e, 0x09, 0x89, 0xbd, 0xf5, 0x41, 0x48, 0x04, - 0x3e, 0xf0, 0xb8, 0xa0, 0x8c, 0xa0, 0x9c, 0x51, 0x41, 0x8d, 0xfd, 0x52, 0x83, 0xae, 0x34, 0x48, - 0x6b, 0x06, 0x77, 0x23, 0xca, 0x33, 0xca, 0xe7, 0x52, 0xe5, 0xa9, 0x40, 0xa5, 0x0c, 0xee, 0x24, - 0x34, 0xa1, 0x0a, 0x2f, 0xff, 0x34, 0x6a, 0x27, 0x94, 0x26, 0x4b, 0xe2, 0xc9, 0x28, 0x5c, 0x1d, - 0x7b, 0x22, 0xcd, 0x08, 0x17, 0x38, 0xcb, 0x95, 0x60, 0xf8, 0x02, 0xb6, 0x66, 0x98, 0xe1, 0x8c, - 0x1b, 0x53, 0xd8, 0xce, 0x30, 0x5b, 0x10, 0xc1, 0x4d, 0xe0, 0x34, 0xdc, 0xde, 0xa1, 0x85, 0x7e, - 0x7f, 0x0a, 0x74, 0x24, 0x65, 0xfe, 0xad, 0xb3, 0xad, 0x5d, 0xfb, 0x78, 0x61, 0xb7, 0x55, 0xcc, - 0x83, 0x2a, 0xff, 0x71, 0xf3, 0xdd, 0x7b, 0xbb, 0x36, 0xfc, 0x01, 0x60, 0x4b, 0x51, 0xc6, 0x03, - 0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xc0, 0x16, 0x39, 0xc9, 0x53, 0xb6, 0x31, 0x9b, 0x0e, 0x70, 0x7b, - 0x87, 0x03, 0xa4, 0xd6, 0x0e, 0x55, 0x6b, 0x87, 0x9e, 0x57, 0x6b, 0xe7, 0x77, 0xca, 0x16, 0xa7, - 0x17, 0x36, 0x08, 0x74, 0x8e, 0x76, 0xed, 0x2d, 0x80, 0xfd, 0xa7, 0x2b, 0xc6, 0xc8, 0x6b, 0x71, - 0x63, 0xdb, 0xae, 0xa6, 0xa8, 0xff, 0xc5, 0x14, 0xea, 0x1c, 0xfe, 0xd1, 0xe5, 0x77, 0x0b, 0x7c, - 0x28, 0x2c, 0x70, 0x56, 0x58, 0xe0, 0xbc, 0xb0, 0xc0, 0x65, 0x61, 0x81, 0xd3, 0x9d, 0x55, 0x3b, - 0xdf, 0x59, 0xb5, 0xaf, 0x3b, 0xab, 0xf6, 0xf2, 0xe1, 0xb5, 0xb2, 0xe5, 0x0b, 0x19, 0x2d, 0x71, - 0xc8, 0xe5, 0x9f, 0x77, 0x72, 0xed, 0x5d, 0xcb, 0xfa, 0x61, 0x4b, 0x5a, 0xf0, 0xe8, 0x57, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x79, 0x54, 0x17, 0x7a, 0xf6, 0x03, 0x00, 0x00, + // 508 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x25, 0x6d, 0xfe, 0x5c, 0x02, 0x48, 0x06, 0x55, 0x26, 0x12, 0x76, 0x94, 0x01, 0x19, + 0xa1, 0x9c, 0xd5, 0xb2, 0xb2, 0xc4, 0x64, 0x20, 0x43, 0xa5, 0xc8, 0x30, 0xb1, 0x44, 0x67, 0xfb, + 0xd5, 0x58, 0x89, 0x39, 0x73, 0x77, 0x89, 0x9a, 0x89, 0xaf, 0xd0, 0x8f, 0x81, 0x90, 0xd8, 0xf8, + 0x10, 0x1d, 0x2b, 0x26, 0xc4, 0x90, 0x16, 0xe7, 0x03, 0xb0, 0x33, 0x21, 0xdf, 0xd9, 0x55, 0x07, + 0x06, 0x2a, 0x98, 0xee, 0xde, 0xef, 0xfd, 0xde, 0xbf, 0xdf, 0xbd, 0xc3, 0xc3, 0x05, 0x5d, 0x53, + 0x37, 0xe3, 0x49, 0x08, 0x27, 0x00, 0x91, 0xbb, 0x3e, 0x0c, 0x40, 0xd2, 0x43, 0x57, 0x48, 0xc6, + 0x81, 0x64, 0x9c, 0x49, 0x66, 0x1c, 0x14, 0x1c, 0x72, 0xcd, 0x21, 0x25, 0xa7, 0xff, 0x30, 0x64, + 0x22, 0x65, 0x62, 0xae, 0x58, 0xae, 0x36, 0x74, 0x48, 0xff, 0x41, 0xcc, 0x62, 0xa6, 0xf1, 0xe2, + 0x56, 0xa2, 0x76, 0xcc, 0x58, 0xbc, 0x04, 0x57, 0x59, 0xc1, 0xea, 0xc4, 0x95, 0x49, 0x0a, 0x42, + 0xd2, 0x34, 0xd3, 0x84, 0xe1, 0x2b, 0xdc, 0x9c, 0x51, 0x4e, 0x53, 0x61, 0x4c, 0x71, 0x2b, 0xa5, + 0x7c, 0x01, 0x52, 0x98, 0x68, 0xd0, 0x70, 0xba, 0x47, 0x16, 0xf9, 0x73, 0x17, 0xe4, 0x58, 0xd1, + 0xbc, 0x7b, 0xe7, 0x5b, 0xbb, 0xf6, 0xe9, 0xd2, 0x6e, 0x69, 0x5b, 0xf8, 0x55, 0xfc, 0xf0, 0x27, + 0xc2, 0x4d, 0x0d, 0x1a, 0x4f, 0x70, 0x47, 0xa3, 0xf3, 0x24, 0x32, 0xd1, 0x00, 0x39, 0x1d, 0xaf, + 0x97, 0x6f, 0xed, 0xb6, 0x76, 0x4f, 0x27, 0x7e, 0x5b, 0xbb, 0xa7, 0x91, 0xf1, 0x08, 0xe3, 0x80, + 0x0a, 0x98, 0x53, 0x21, 0x40, 0x9a, 0xf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 0x7b, 0x2f, 0x56, 0x9c, + 0xc3, 0x3b, 0x79, 0x6b, 0xbd, 0xae, 0xdb, 0xaf, 0xff, 0x43, 0xfb, 0xde, 0xf1, 0xd5, 0x0f, 0x0b, + 0x7d, 0xcc, 0x2d, 0x74, 0x9e, 0x5b, 0xe8, 0x22, 0xb7, 0xd0, 0x55, 0x6e, 0xa1, 0xb3, 0x9d, 0x55, + 0xbb, 0xd8, 0x59, 0xb5, 0x6f, 0x3b, 0xab, 0xf6, 0xe6, 0xe9, 0x8d, 0x84, 0xc5, 0x47, 0x18, 0x2d, + 0x69, 0x20, 0xd4, 0xcd, 0x3d, 0xbd, 0xf1, 0x7d, 0x55, 0xe6, 0xa0, 0xa9, 0xa6, 0x7e, 0xf6, 0x3b, + 0x00, 0x00, 0xff, 0xff, 0x18, 0xb5, 0x5b, 0xc1, 0xdd, 0x03, 0x00, 0x00, } func (this *Params) VerboseEqual(that interface{}) error {