diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f771732d..1307f379b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### State Machine Breaking * [#1473](https://github.com/NibiruChain/nibiru/pull/1473) - refactor(perp)!: rename `OpenPosition` to `MarketOrder` +* [#1477](https://github.com/NibiruChain/nibiru/pull/1477) - refactor(oracle)!: Move away from deprecated events to typed events in x/oracle ### Dependencies diff --git a/proto/nibiru/oracle/v1/event.proto b/proto/nibiru/oracle/v1/event.proto index 016308827..73acb862f 100644 --- a/proto/nibiru/oracle/v1/event.proto +++ b/proto/nibiru/oracle/v1/event.proto @@ -2,13 +2,14 @@ syntax = "proto3"; package nibiru.oracle.v1; +import "nibiru/oracle/v1/oracle.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; option go_package = "github.com/NibiruChain/nibiru/x/oracle/types"; // Emitted when a price is posted -message OraclePriceUpdate { +message EventPriceUpdate { string pair = 1; string price = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", @@ -16,3 +17,39 @@ message OraclePriceUpdate { ]; int64 timestamp_ms = 3; } + +// Emitted when a valoper delegates oracle voting rights to a feeder address. +message EventDelegateFeederConsent { + // Validator is the Bech32 address that is delegating voting rights. + string validator = 1; + + // Feeder is the delegate or representative that will be able to send + // vote and prevote transaction messages. + string feeder = 2; +} + +// Emitted by MsgAggregateExchangeVote when an aggregate vote is added to state +message EventAggregateVote { + // Validator is the Bech32 address to which the vote will be credited. + string validator = 1; + + // Feeder is the delegate or representative that will send vote and prevote + // transaction messages on behalf of the voting validator. + string feeder = 2; + + repeated ExchangeRateTuple prices = 3 [ + (gogoproto.castrepeated) = "ExchangeRateTuples", + (gogoproto.nullable) = false + ]; +} + +// Emitted by MsgAggregateExchangePrevote when an aggregate prevote is added +// to state +message EventAggregatePrevote { + // Validator is the Bech32 address to which the vote will be credited. + string validator = 1; + + // Feeder is the delegate or representative that will send vote and prevote + // transaction messages on behalf of the voting validator. + string feeder = 2; +} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index d81915bb8..f23b6ad7e 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -180,7 +180,7 @@ func (k Keeper) SetPrice(ctx sdk.Context, pair asset.Pair, price sdk.Dec) { Price: price, TimestampMs: timestampMs, }) - if err := ctx.EventManager().EmitTypedEvent(&types.OraclePriceUpdate{ + if err := ctx.EventManager().EmitTypedEvent(&types.EventPriceUpdate{ Pair: pair.String(), Price: price, TimestampMs: timestampMs, diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 1fa2fbbd6..7bed77107 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -50,22 +50,16 @@ func (ms msgServer) AggregateExchangeRatePrevote( ms.Keeper.Prevotes.Insert(ctx, valAddr, types.NewAggregateExchangeRatePrevote(voteHash, valAddr, uint64(ctx.BlockHeight()))) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAggregatePrevote, - sdk.NewAttribute(types.AttributeKeyVoter, msg.Validator), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Feeder), - ), + err = ctx.EventManager().EmitTypedEvent(&types.EventAggregatePrevote{ + Validator: msg.Validator, + Feeder: msg.Feeder, }) - - return &types.MsgAggregateExchangeRatePrevoteResponse{}, nil + return &types.MsgAggregateExchangeRatePrevoteResponse{}, err } -func (ms msgServer) AggregateExchangeRateVote(goCtx context.Context, msg *types.MsgAggregateExchangeRateVote) (*types.MsgAggregateExchangeRateVoteResponse, error) { +func (ms msgServer) AggregateExchangeRateVote( + goCtx context.Context, msg *types.MsgAggregateExchangeRateVote, +) (msgResp *types.MsgAggregateExchangeRateVoteResponse, err error) { ctx := sdk.UnwrapSDKContext(goCtx) valAddr, err := sdk.ValAddressFromBech32(msg.Validator) @@ -118,30 +112,33 @@ func (ms msgServer) AggregateExchangeRateVote(goCtx context.Context, msg *types. // Verify an exchange rate with aggregate prevote hash hash := types.GetAggregateVoteHash(msg.Salt, msg.ExchangeRates, valAddr) if aggregatePrevote.Hash != hash.String() { - return nil, sdkerrors.Wrapf(types.ErrVerificationFailed, "must be given %s not %s", aggregatePrevote.Hash, hash) + return nil, sdkerrors.Wrapf( + types.ErrVerificationFailed, "must be given %s not %s", aggregatePrevote.Hash, hash, + ) } // Move aggregate prevote to aggregate vote with given exchange rates - ms.Keeper.Votes.Insert(ctx, valAddr, types.NewAggregateExchangeRateVote(exchangeRateTuples, valAddr)) + ms.Keeper.Votes.Insert( + ctx, valAddr, types.NewAggregateExchangeRateVote(exchangeRateTuples, valAddr), + ) _ = ms.Keeper.Prevotes.Delete(ctx, valAddr) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAggregateVote, - sdk.NewAttribute(types.AttributeKeyVoter, msg.Validator), - sdk.NewAttribute(types.AttributeKeyExchangeRates, msg.ExchangeRates), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Feeder), - ), + priceTuples, err := types.NewExchangeRateTuplesFromString(msg.ExchangeRates) + if err != nil { + return + } + err = ctx.EventManager().EmitTypedEvent(&types.EventAggregateVote{ + Validator: msg.Validator, + Feeder: msg.Feeder, + Prices: priceTuples, }) - return &types.MsgAggregateExchangeRateVoteResponse{}, nil + return &types.MsgAggregateExchangeRateVoteResponse{}, err } -func (ms msgServer) DelegateFeedConsent(goCtx context.Context, msg *types.MsgDelegateFeedConsent) (*types.MsgDelegateFeedConsentResponse, error) { +func (ms msgServer) DelegateFeedConsent( + goCtx context.Context, msg *types.MsgDelegateFeedConsent, +) (*types.MsgDelegateFeedConsentResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) operatorAddr, err := sdk.ValAddressFromBech32(msg.Operator) @@ -163,17 +160,10 @@ func (ms msgServer) DelegateFeedConsent(goCtx context.Context, msg *types.MsgDel // Set the delegation ms.Keeper.FeederDelegations.Insert(ctx, operatorAddr, delegateAddr) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeFeedDelegate, - sdk.NewAttribute(types.AttributeKeyFeeder, msg.Delegate), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Operator), - ), + err = ctx.EventManager().EmitTypedEvent(&types.EventDelegateFeederConsent{ + Feeder: msg.Delegate, + Validator: msg.Operator, }) - return &types.MsgDelegateFeedConsentResponse{}, nil + return &types.MsgDelegateFeedConsentResponse{}, err } diff --git a/x/oracle/keeper/querier_test.go b/x/oracle/keeper/querier_test.go index d01a9c328..a520a9a1d 100644 --- a/x/oracle/keeper/querier_test.go +++ b/x/oracle/keeper/querier_test.go @@ -97,7 +97,7 @@ func TestQueryExchangeRateTwap(t *testing.T) { testutilevents.RequireContainsTypedEvent( t, input.Ctx, - &types.OraclePriceUpdate{ + &types.EventPriceUpdate{ Pair: asset.Registry.Pair(denoms.BTC, denoms.NUSD).String(), Price: rate, TimestampMs: input.Ctx.BlockTime().UnixMilli()}, diff --git a/x/oracle/keeper/update_exchange_rates.go b/x/oracle/keeper/update_exchange_rates.go index a20268f98..429ff7b85 100644 --- a/x/oracle/keeper/update_exchange_rates.go +++ b/x/oracle/keeper/update_exchange_rates.go @@ -64,12 +64,11 @@ func (k Keeper) countVotesAndUpdateExchangeRates( k.SetPrice(ctx, pair, exchangeRate) - ctx.EventManager().EmitEvent( - sdk.NewEvent(types.EventTypeExchangeRateUpdate, - sdk.NewAttribute(types.AttributeKeyPair, pair.String()), - sdk.NewAttribute(types.AttributeKeyExchangeRate, exchangeRate.String()), - ), - ) + _ = ctx.EventManager().EmitTypedEvent(&types.EventPriceUpdate{ + Pair: pairStr, + Price: exchangeRate, + TimestampMs: ctx.BlockTime().UnixMilli(), + }) } } diff --git a/x/oracle/types/event.pb.go b/x/oracle/types/event.pb.go index 5cd764db0..085a6c8ef 100644 --- a/x/oracle/types/event.pb.go +++ b/x/oracle/types/event.pb.go @@ -26,24 +26,24 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Emitted when a price is posted -type OraclePriceUpdate struct { +type EventPriceUpdate struct { Pair string `protobuf:"bytes,1,opt,name=pair,proto3" json:"pair,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"` TimestampMs int64 `protobuf:"varint,3,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"` } -func (m *OraclePriceUpdate) Reset() { *m = OraclePriceUpdate{} } -func (m *OraclePriceUpdate) String() string { return proto.CompactTextString(m) } -func (*OraclePriceUpdate) ProtoMessage() {} -func (*OraclePriceUpdate) Descriptor() ([]byte, []int) { +func (m *EventPriceUpdate) Reset() { *m = EventPriceUpdate{} } +func (m *EventPriceUpdate) String() string { return proto.CompactTextString(m) } +func (*EventPriceUpdate) ProtoMessage() {} +func (*EventPriceUpdate) Descriptor() ([]byte, []int) { return fileDescriptor_94ec441b793fc0ea, []int{0} } -func (m *OraclePriceUpdate) XXX_Unmarshal(b []byte) error { +func (m *EventPriceUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *OraclePriceUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventPriceUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_OraclePriceUpdate.Marshal(b, m, deterministic) + return xxx_messageInfo_EventPriceUpdate.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -53,61 +53,249 @@ func (m *OraclePriceUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *OraclePriceUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_OraclePriceUpdate.Merge(m, src) +func (m *EventPriceUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPriceUpdate.Merge(m, src) } -func (m *OraclePriceUpdate) XXX_Size() int { +func (m *EventPriceUpdate) XXX_Size() int { return m.Size() } -func (m *OraclePriceUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_OraclePriceUpdate.DiscardUnknown(m) +func (m *EventPriceUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_EventPriceUpdate.DiscardUnknown(m) } -var xxx_messageInfo_OraclePriceUpdate proto.InternalMessageInfo +var xxx_messageInfo_EventPriceUpdate proto.InternalMessageInfo -func (m *OraclePriceUpdate) GetPair() string { +func (m *EventPriceUpdate) GetPair() string { if m != nil { return m.Pair } return "" } -func (m *OraclePriceUpdate) GetTimestampMs() int64 { +func (m *EventPriceUpdate) GetTimestampMs() int64 { if m != nil { return m.TimestampMs } return 0 } +// Emitted when a valoper delegates oracle voting rights to a feeder address. +type EventDelegateFeederConsent struct { + // Validator is the Bech32 address that is delegating voting rights. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Feeder is the delegate or representative that will be able to send + // vote and prevote transaction messages. + Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty"` +} + +func (m *EventDelegateFeederConsent) Reset() { *m = EventDelegateFeederConsent{} } +func (m *EventDelegateFeederConsent) String() string { return proto.CompactTextString(m) } +func (*EventDelegateFeederConsent) ProtoMessage() {} +func (*EventDelegateFeederConsent) Descriptor() ([]byte, []int) { + return fileDescriptor_94ec441b793fc0ea, []int{1} +} +func (m *EventDelegateFeederConsent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventDelegateFeederConsent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventDelegateFeederConsent.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 *EventDelegateFeederConsent) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventDelegateFeederConsent.Merge(m, src) +} +func (m *EventDelegateFeederConsent) XXX_Size() int { + return m.Size() +} +func (m *EventDelegateFeederConsent) XXX_DiscardUnknown() { + xxx_messageInfo_EventDelegateFeederConsent.DiscardUnknown(m) +} + +var xxx_messageInfo_EventDelegateFeederConsent proto.InternalMessageInfo + +func (m *EventDelegateFeederConsent) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *EventDelegateFeederConsent) GetFeeder() string { + if m != nil { + return m.Feeder + } + return "" +} + +// Emitted by MsgAggregateExchangeVote when an aggregate vote is added to state +type EventAggregateVote struct { + // Validator is the Bech32 address to which the vote will be credited. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Feeder is the delegate or representative that will send vote and prevote + // transaction messages on behalf of the voting validator. + Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty"` + Prices ExchangeRateTuples `protobuf:"bytes,3,rep,name=prices,proto3,castrepeated=ExchangeRateTuples" json:"prices"` +} + +func (m *EventAggregateVote) Reset() { *m = EventAggregateVote{} } +func (m *EventAggregateVote) String() string { return proto.CompactTextString(m) } +func (*EventAggregateVote) ProtoMessage() {} +func (*EventAggregateVote) Descriptor() ([]byte, []int) { + return fileDescriptor_94ec441b793fc0ea, []int{2} +} +func (m *EventAggregateVote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventAggregateVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventAggregateVote.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 *EventAggregateVote) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventAggregateVote.Merge(m, src) +} +func (m *EventAggregateVote) XXX_Size() int { + return m.Size() +} +func (m *EventAggregateVote) XXX_DiscardUnknown() { + xxx_messageInfo_EventAggregateVote.DiscardUnknown(m) +} + +var xxx_messageInfo_EventAggregateVote proto.InternalMessageInfo + +func (m *EventAggregateVote) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *EventAggregateVote) GetFeeder() string { + if m != nil { + return m.Feeder + } + return "" +} + +func (m *EventAggregateVote) GetPrices() ExchangeRateTuples { + if m != nil { + return m.Prices + } + return nil +} + +// Emitted by MsgAggregateExchangePrevote when an aggregate prevote is added +// to state +type EventAggregatePrevote struct { + // Validator is the Bech32 address to which the vote will be credited. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Feeder is the delegate or representative that will send vote and prevote + // transaction messages on behalf of the voting validator. + Feeder string `protobuf:"bytes,2,opt,name=feeder,proto3" json:"feeder,omitempty"` +} + +func (m *EventAggregatePrevote) Reset() { *m = EventAggregatePrevote{} } +func (m *EventAggregatePrevote) String() string { return proto.CompactTextString(m) } +func (*EventAggregatePrevote) ProtoMessage() {} +func (*EventAggregatePrevote) Descriptor() ([]byte, []int) { + return fileDescriptor_94ec441b793fc0ea, []int{3} +} +func (m *EventAggregatePrevote) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventAggregatePrevote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventAggregatePrevote.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 *EventAggregatePrevote) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventAggregatePrevote.Merge(m, src) +} +func (m *EventAggregatePrevote) XXX_Size() int { + return m.Size() +} +func (m *EventAggregatePrevote) XXX_DiscardUnknown() { + xxx_messageInfo_EventAggregatePrevote.DiscardUnknown(m) +} + +var xxx_messageInfo_EventAggregatePrevote proto.InternalMessageInfo + +func (m *EventAggregatePrevote) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *EventAggregatePrevote) GetFeeder() string { + if m != nil { + return m.Feeder + } + return "" +} + func init() { - proto.RegisterType((*OraclePriceUpdate)(nil), "nibiru.oracle.v1.OraclePriceUpdate") + proto.RegisterType((*EventPriceUpdate)(nil), "nibiru.oracle.v1.EventPriceUpdate") + proto.RegisterType((*EventDelegateFeederConsent)(nil), "nibiru.oracle.v1.EventDelegateFeederConsent") + proto.RegisterType((*EventAggregateVote)(nil), "nibiru.oracle.v1.EventAggregateVote") + proto.RegisterType((*EventAggregatePrevote)(nil), "nibiru.oracle.v1.EventAggregatePrevote") } func init() { proto.RegisterFile("nibiru/oracle/v1/event.proto", fileDescriptor_94ec441b793fc0ea) } var fileDescriptor_94ec441b793fc0ea = []byte{ - // 276 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcd, 0x4a, 0x03, 0x31, - 0x14, 0x85, 0x27, 0x56, 0x05, 0x47, 0x17, 0x3a, 0xb8, 0x18, 0x4a, 0x49, 0xab, 0x0b, 0xe9, 0x42, - 0x13, 0x8a, 0x6f, 0x50, 0x8b, 0x3b, 0x7f, 0x18, 0x70, 0xe3, 0x46, 0x32, 0xd3, 0x30, 0x0d, 0x36, - 0xb9, 0x21, 0x49, 0x07, 0x7d, 0x8b, 0x3e, 0x56, 0x97, 0x5d, 0x8a, 0x8b, 0x22, 0x33, 0x2f, 0x22, - 0x93, 0x54, 0xe9, 0x2a, 0x97, 0xfb, 0x9d, 0xdc, 0xc3, 0x39, 0x71, 0x4f, 0x89, 0x5c, 0x98, 0x05, - 0x05, 0xc3, 0x8a, 0x39, 0xa7, 0xd5, 0x88, 0xf2, 0x8a, 0x2b, 0x47, 0xb4, 0x01, 0x07, 0xc9, 0x69, - 0xa0, 0x24, 0x50, 0x52, 0x8d, 0xba, 0xe7, 0x25, 0x94, 0xe0, 0x21, 0x6d, 0xa7, 0xa0, 0xeb, 0xf6, - 0x4a, 0x80, 0x72, 0xce, 0x29, 0xd3, 0x82, 0x32, 0xa5, 0xc0, 0x31, 0x27, 0x40, 0xd9, 0x40, 0x2f, - 0x97, 0x28, 0x3e, 0x7b, 0xf2, 0x17, 0x9e, 0x8d, 0x28, 0xf8, 0x8b, 0x9e, 0x32, 0xc7, 0x93, 0x24, - 0xde, 0xd7, 0x4c, 0x98, 0x14, 0x0d, 0xd0, 0xf0, 0x28, 0xf3, 0x73, 0x32, 0x89, 0x0f, 0x74, 0x2b, - 0x49, 0xf7, 0xda, 0xe5, 0x98, 0xac, 0x36, 0xfd, 0xe8, 0x7b, 0xd3, 0xbf, 0x2a, 0x85, 0x9b, 0x2d, - 0x72, 0x52, 0x80, 0xa4, 0x05, 0x58, 0x09, 0x76, 0xfb, 0xdc, 0xd8, 0xe9, 0x3b, 0x75, 0x9f, 0x9a, - 0x5b, 0x32, 0xe1, 0x45, 0x16, 0x3e, 0x27, 0x17, 0xf1, 0x89, 0x13, 0x92, 0x5b, 0xc7, 0xa4, 0x7e, - 0x93, 0x36, 0xed, 0x0c, 0xd0, 0xb0, 0x93, 0x1d, 0xff, 0xef, 0x1e, 0xec, 0xf8, 0x7e, 0x55, 0x63, - 0xb4, 0xae, 0x31, 0xfa, 0xa9, 0x31, 0x5a, 0x36, 0x38, 0x5a, 0x37, 0x38, 0xfa, 0x6a, 0x70, 0xf4, - 0x7a, 0xbd, 0xe3, 0xf5, 0xe8, 0xd3, 0xdf, 0xcd, 0x98, 0x50, 0x74, 0xdb, 0xd3, 0xc7, 0x5f, 0x53, - 0xde, 0x35, 0x3f, 0xf4, 0x09, 0x6f, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x02, 0x4f, 0x68, - 0x47, 0x01, 0x00, 0x00, -} - -func (m *OraclePriceUpdate) Marshal() (dAtA []byte, err error) { + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcd, 0x8e, 0xd3, 0x30, + 0x14, 0x85, 0x63, 0x0a, 0x95, 0xc6, 0xc3, 0x62, 0x64, 0x01, 0xaa, 0xa2, 0x92, 0x0e, 0x41, 0x42, + 0x5d, 0x80, 0xad, 0x81, 0x27, 0xa0, 0xd3, 0x99, 0xdd, 0xa0, 0x51, 0xc4, 0x8f, 0xc4, 0x06, 0xb9, + 0xc9, 0xc5, 0xb5, 0x48, 0x6c, 0xcb, 0x76, 0xa3, 0xe1, 0x29, 0xe0, 0x1d, 0xd8, 0xf1, 0x24, 0xb3, + 0xec, 0x12, 0xb1, 0x28, 0xa8, 0x7d, 0x11, 0x14, 0x27, 0xe5, 0xaf, 0xbb, 0xae, 0x72, 0x73, 0xce, + 0xf5, 0xc9, 0x17, 0xdf, 0x8b, 0x87, 0x4a, 0xce, 0xa4, 0x5d, 0x30, 0x6d, 0x79, 0x5e, 0x02, 0xab, + 0x4f, 0x18, 0xd4, 0xa0, 0x3c, 0x35, 0x56, 0x7b, 0x4d, 0x8e, 0x5a, 0x97, 0xb6, 0x2e, 0xad, 0x4f, + 0xe2, 0xfb, 0x3b, 0xfd, 0x9d, 0x17, 0x0e, 0xc4, 0x77, 0x84, 0x16, 0x3a, 0x94, 0xac, 0xa9, 0x3a, + 0x75, 0x28, 0xb4, 0x16, 0x25, 0x30, 0x6e, 0x24, 0xe3, 0x4a, 0x69, 0xcf, 0xbd, 0xd4, 0xca, 0xb5, + 0x6e, 0xfa, 0x09, 0xe1, 0xa3, 0xb3, 0xe6, 0xa3, 0x97, 0x56, 0xe6, 0xf0, 0xca, 0x14, 0xdc, 0x03, + 0x21, 0xf8, 0xa6, 0xe1, 0xd2, 0x0e, 0xd0, 0x31, 0x1a, 0x1f, 0x64, 0xa1, 0x26, 0x53, 0x7c, 0xcb, + 0x34, 0x2d, 0x83, 0x1b, 0x8d, 0x38, 0xa1, 0xd7, 0xab, 0x51, 0xf4, 0x7d, 0x35, 0x7a, 0x24, 0xa4, + 0x9f, 0x2f, 0x66, 0x34, 0xd7, 0x15, 0xcb, 0xb5, 0xab, 0xb4, 0xeb, 0x1e, 0x4f, 0x5c, 0xf1, 0x81, + 0xf9, 0x8f, 0x06, 0x1c, 0x9d, 0x42, 0x9e, 0xb5, 0x87, 0xc9, 0x03, 0x7c, 0xdb, 0xcb, 0x0a, 0x9c, + 0xe7, 0x95, 0x79, 0x57, 0xb9, 0x41, 0xef, 0x18, 0x8d, 0x7b, 0xd9, 0xe1, 0x6f, 0xed, 0xc2, 0xa5, + 0x19, 0x8e, 0x03, 0xd0, 0x14, 0x4a, 0x10, 0xdc, 0xc3, 0x39, 0x40, 0x01, 0xf6, 0x54, 0x2b, 0x07, + 0xca, 0x93, 0x21, 0x3e, 0xa8, 0x79, 0x29, 0x0b, 0xee, 0xf5, 0x96, 0xef, 0x8f, 0x40, 0xee, 0xe1, + 0xfe, 0xfb, 0xd0, 0xde, 0x52, 0x66, 0xdd, 0x5b, 0xfa, 0x05, 0x61, 0x12, 0x42, 0x9f, 0x0b, 0x61, + 0x43, 0xea, 0x6b, 0xed, 0x61, 0xbf, 0x30, 0xf2, 0x06, 0xf7, 0xc3, 0xcf, 0x34, 0xf4, 0xbd, 0xf1, + 0xe1, 0xd3, 0x87, 0xf4, 0xff, 0x41, 0xd1, 0xb3, 0xab, 0x7c, 0xce, 0x95, 0x80, 0x8c, 0x7b, 0x78, + 0xb9, 0x30, 0x25, 0x4c, 0xe2, 0xe6, 0xbe, 0xbe, 0xfe, 0x18, 0x91, 0x1d, 0xcb, 0x65, 0x5d, 0x5c, + 0x7a, 0x81, 0xef, 0xfe, 0x0b, 0x79, 0x69, 0xa1, 0xde, 0x9b, 0x73, 0x72, 0x7e, 0xbd, 0x4e, 0xd0, + 0x72, 0x9d, 0xa0, 0x9f, 0xeb, 0x04, 0x7d, 0xde, 0x24, 0xd1, 0x72, 0x93, 0x44, 0xdf, 0x36, 0x49, + 0xf4, 0xf6, 0xf1, 0x5f, 0x43, 0x7b, 0x11, 0xd8, 0x4f, 0xe7, 0x5c, 0x2a, 0xd6, 0xad, 0xd7, 0xd5, + 0x76, 0xc1, 0xc2, 0xf8, 0x66, 0xfd, 0xb0, 0x29, 0xcf, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0x3b, + 0xea, 0x2b, 0x3c, 0xae, 0x02, 0x00, 0x00, +} + +func (m *EventPriceUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -117,12 +305,12 @@ func (m *OraclePriceUpdate) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *OraclePriceUpdate) MarshalTo(dAtA []byte) (int, error) { +func (m *EventPriceUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *OraclePriceUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventPriceUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -152,6 +340,131 @@ func (m *OraclePriceUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventDelegateFeederConsent) 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 *EventDelegateFeederConsent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventDelegateFeederConsent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Feeder) > 0 { + i -= len(m.Feeder) + copy(dAtA[i:], m.Feeder) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Feeder))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventAggregateVote) 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 *EventAggregateVote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventAggregateVote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Feeder) > 0 { + i -= len(m.Feeder) + copy(dAtA[i:], m.Feeder) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Feeder))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventAggregatePrevote) 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 *EventAggregatePrevote) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventAggregatePrevote) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Feeder) > 0 { + i -= len(m.Feeder) + copy(dAtA[i:], m.Feeder) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Feeder))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { offset -= sovEvent(v) base := offset @@ -163,7 +476,7 @@ func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *OraclePriceUpdate) Size() (n int) { +func (m *EventPriceUpdate) Size() (n int) { if m == nil { return 0 } @@ -181,13 +494,70 @@ func (m *OraclePriceUpdate) Size() (n int) { return n } +func (m *EventDelegateFeederConsent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Feeder) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func (m *EventAggregateVote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Feeder) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if len(m.Prices) > 0 { + for _, e := range m.Prices { + l = e.Size() + n += 1 + l + sovEvent(uint64(l)) + } + } + return n +} + +func (m *EventAggregatePrevote) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Feeder) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + func sovEvent(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozEvent(x uint64) (n int) { return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *OraclePriceUpdate) Unmarshal(dAtA []byte) error { +func (m *EventPriceUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -210,10 +580,10 @@ func (m *OraclePriceUpdate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: OraclePriceUpdate: wiretype end group for non-group") + return fmt.Errorf("proto: EventPriceUpdate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: OraclePriceUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventPriceUpdate: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -322,6 +692,382 @@ func (m *OraclePriceUpdate) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventDelegateFeederConsent) 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 ErrIntOverflowEvent + } + 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: EventDelegateFeederConsent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventDelegateFeederConsent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Feeder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventAggregateVote) 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 ErrIntOverflowEvent + } + 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: EventAggregateVote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventAggregateVote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Feeder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Prices = append(m.Prices, ExchangeRateTuple{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventAggregatePrevote) 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 ErrIntOverflowEvent + } + 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: EventAggregatePrevote: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventAggregatePrevote: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Feeder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Feeder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvent(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/oracle/types/events.go b/x/oracle/types/events.go deleted file mode 100644 index 91be4c9ab..000000000 --- a/x/oracle/types/events.go +++ /dev/null @@ -1,20 +0,0 @@ -package types - -// Oracle module event types -const ( - EventTypeExchangeRateUpdate = "exchange_rate_update" - EventTypePrevote = "prevote" - EventTypeVote = "vote" - EventTypeFeedDelegate = "feed_delegate" - EventTypeAggregatePrevote = "aggregate_prevote" - EventTypeAggregateVote = "aggregate_vote" - - AttributeKeyPair = "pair" - AttributeKeyVoter = "voter" - AttributeKeyExchangeRate = "exchange_rate" - AttributeKeyExchangeRates = "exchange_rates" - AttributeKeyOperator = "operator" - AttributeKeyFeeder = "feeder" - - AttributeValueCategory = ModuleName -) diff --git a/x/oracle/types/vote.go b/x/oracle/types/vote.go index 341cc267f..a82e6d351 100644 --- a/x/oracle/types/vote.go +++ b/x/oracle/types/vote.go @@ -83,7 +83,7 @@ func (m ExchangeRateTuple) ToString() (string, error) { func NewExchangeRateTupleFromString(s string) (ExchangeRateTuple, error) { // strip parentheses if len(s) <= 2 { - return ExchangeRateTuple{}, fmt.Errorf("invalid string length") + return ExchangeRateTuple{}, fmt.Errorf("invalid string length: %v", len(s)) } if s[0] != ExchangeRateTupleStringPrefix || s[len(s)-1] != ExchangeRateTupleStringSuffix { diff --git a/x/oracle/types/vote_test.go b/x/oracle/types/vote_test.go index d6bb130c5..1480d750b 100644 --- a/x/oracle/types/vote_test.go +++ b/x/oracle/types/vote_test.go @@ -10,7 +10,7 @@ import ( "github.com/NibiruChain/nibiru/x/oracle/types" ) -func TestParseExchangeRateTuples(t *testing.T) { +func TestExchangeRateTuples_ToString(t *testing.T) { t.Run("inverse", func(t *testing.T) { tuples := types.ExchangeRateTuples{ {