From 6fb2be13b2feeed301014a8270fa474bee70dbaa Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 5 Dec 2024 20:34:37 +0200 Subject: [PATCH 001/115] scaffold x/icqoracle --- app/app.go | 20 ++ proto/stride/icqoracle/genesis.proto | 19 ++ x/icqoracle/keeper/abci.go | 5 + x/icqoracle/keeper/genesis.go | 19 ++ x/icqoracle/keeper/keeper.go | 29 ++ x/icqoracle/module.go | 162 ++++++++++ x/icqoracle/types/codec.go | 39 +++ x/icqoracle/types/expected_keepers.go | 22 ++ x/icqoracle/types/genesis.go | 12 + x/icqoracle/types/genesis.pb.go | 442 ++++++++++++++++++++++++++ x/icqoracle/types/keys.go | 8 + x/icqoracle/types/params.go | 16 + 12 files changed, 793 insertions(+) create mode 100644 proto/stride/icqoracle/genesis.proto create mode 100644 x/icqoracle/keeper/abci.go create mode 100644 x/icqoracle/keeper/genesis.go create mode 100644 x/icqoracle/keeper/keeper.go create mode 100644 x/icqoracle/module.go create mode 100644 x/icqoracle/types/codec.go create mode 100644 x/icqoracle/types/expected_keepers.go create mode 100644 x/icqoracle/types/genesis.go create mode 100644 x/icqoracle/types/genesis.pb.go create mode 100644 x/icqoracle/types/keys.go create mode 100644 x/icqoracle/types/params.go diff --git a/app/app.go b/app/app.go index 721c889d7a..292b434443 100644 --- a/app/app.go +++ b/app/app.go @@ -146,6 +146,9 @@ import ( icaoracle "github.com/Stride-Labs/stride/v24/x/icaoracle" icaoraclekeeper "github.com/Stride-Labs/stride/v24/x/icaoracle/keeper" icaoracletypes "github.com/Stride-Labs/stride/v24/x/icaoracle/types" + icqoracle "github.com/Stride-Labs/stride/v24/x/icqoracle" + icqoraclekeeper "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" + icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" "github.com/Stride-Labs/stride/v24/x/interchainquery" interchainquerykeeper "github.com/Stride-Labs/stride/v24/x/interchainquery/keeper" interchainquerytypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" @@ -236,6 +239,7 @@ var ( ibchooks.AppModuleBasic{}, ibcwasm.AppModuleBasic{}, airdrop.AppModuleBasic{}, + icqoracle.AppModuleBasic{}, ) // module account permissions @@ -348,6 +352,7 @@ type StrideApp struct { StaketiaKeeper staketiakeeper.Keeper StakedymKeeper stakedymkeeper.Keeper AirdropKeeper airdropkeeper.Keeper + ICQOracleKeeper icqoraclekeeper.Keeper mm *module.Manager sm *module.SimulationManager @@ -404,6 +409,7 @@ func NewStrideApp( ibchookstypes.StoreKey, ibcwasmtypes.StoreKey, airdroptypes.StoreKey, + icqoracletypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -757,6 +763,15 @@ func NewStrideApp( app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.StakingKeeper, ) + // ICQOracle Keeper must be initialized after TransferKeeper + app.ICQOracleKeeper = *icqoraclekeeper.NewKeeper( + appCodec, + keys[icqoracletypes.StoreKey], + app.BankKeeper, + app.TransferKeeper, + ) + icqOracleModule := icqoracle.NewAppModule(appCodec, app.ICQOracleKeeper) + // Register Gov (must be registered after stakeibc) govRouter := govtypesv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). @@ -933,6 +948,8 @@ func NewStrideApp( stakeTiaModule, stakeDymModule, airdropModule, + stakeTiaModule, + icqOracleModule, ) // During begin block slashing happens after distr.BeginBlocker so that @@ -978,6 +995,7 @@ func NewStrideApp( ibchookstypes.ModuleName, ibcwasmtypes.ModuleName, airdroptypes.ModuleName, + icqoracletypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -1019,6 +1037,7 @@ func NewStrideApp( ibchookstypes.ModuleName, ibcwasmtypes.ModuleName, airdroptypes.ModuleName, + icqoracletypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -1065,6 +1084,7 @@ func NewStrideApp( ibchookstypes.ModuleName, ibcwasmtypes.ModuleName, airdroptypes.ModuleName, + icqoracletypes.ModuleName, ) app.mm.RegisterInvariants(app.CrisisKeeper) diff --git a/proto/stride/icqoracle/genesis.proto b/proto/stride/icqoracle/genesis.proto new file mode 100644 index 0000000000..36926e434c --- /dev/null +++ b/proto/stride/icqoracle/genesis.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package stride.icqoracle; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; + +// Params defines the icqoracle module parameters. +message Params {} + +// GenesisState defines the icqoracle module's genesis state. +message GenesisState { + Params params = 1 [ + (gogoproto.moretags) = "yaml:\"params\"", + (gogoproto.nullable) = false + ]; + + // TODO: Add data structures +} \ No newline at end of file diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go new file mode 100644 index 0000000000..a1b817e17a --- /dev/null +++ b/x/icqoracle/keeper/abci.go @@ -0,0 +1,5 @@ +package keeper + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func (k Keeper) BeginBlocker(ctx sdk.Context) {} diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go new file mode 100644 index 0000000000..d6e5c3217d --- /dev/null +++ b/x/icqoracle/keeper/genesis.go @@ -0,0 +1,19 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +// Initializes the genesis state in the store +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + // TODO: InitGenesis +} + +// Exports the current state +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + genesis := types.DefaultGenesis() + // TODO: InitGenesis + return genesis +} diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go new file mode 100644 index 0000000000..4282048a1d --- /dev/null +++ b/x/icqoracle/keeper/keeper.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + bankKeeper types.BankKeeper + transferKeeper types.TransferKeeper +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + bankKeeper types.BankKeeper, + transferKeeper types.TransferKeeper, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + bankKeeper: bankKeeper, + transferKeeper: transferKeeper, + } +} diff --git a/x/icqoracle/module.go b/x/icqoracle/module.go new file mode 100644 index 0000000000..3a22d5ded0 --- /dev/null +++ b/x/icqoracle/module.go @@ -0,0 +1,162 @@ +package icqoracle + +import ( + "encoding/json" + "fmt" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // TODO: Queries + // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + // panic(err) + // } +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + // TODO: messages + // return cli.GetTxCmd() + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + // TODO: Queries + // return cli.GetQueryCmd() + return nil +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + // TODO: Queries and Messages + // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + am.keeper.InitGenesis(ctx, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + am.keeper.BeginBlocker(ctx) +} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/icqoracle/types/codec.go b/x/icqoracle/types/codec.go new file mode 100644 index 0000000000..706c317048 --- /dev/null +++ b/x/icqoracle/types/codec.go @@ -0,0 +1,39 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" +) + +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // TODO [msgserver]: register legacy amino for each msg + // legacy.RegisterAminoMsg(cdc, &MsgSomeMessage{}, "icqoracle/MsgSomeMessage") + _ = legacy.Cdc // remove +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // TODO [msgserver]: add implement sdk.Msg interface for message types + // registry.RegisterImplementations((*sdk.Msg)(nil), ...) + // msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + _ = msgservice.E_Service // remove +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be + // used to properly serialize MsgSubmitProposal instances + RegisterLegacyAminoCodec(govcodec.Amino) +} diff --git a/x/icqoracle/types/expected_keepers.go b/x/icqoracle/types/expected_keepers.go new file mode 100644 index 0000000000..6d2b52961e --- /dev/null +++ b/x/icqoracle/types/expected_keepers.go @@ -0,0 +1,22 @@ +package types + +import ( + context "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" +) + +// Required BankKeeper functions +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetSupply(ctx sdk.Context, denom string) sdk.Coin + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error +} + +// Required TransferKeeper functions +type TransferKeeper interface { + Transfer(goCtx context.Context, msg *transfertypes.MsgTransfer) (*transfertypes.MsgTransferResponse, error) +} diff --git a/x/icqoracle/types/genesis.go b/x/icqoracle/types/genesis.go new file mode 100644 index 0000000000..8837ec5300 --- /dev/null +++ b/x/icqoracle/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Performs basic genesis state validation +func (gs GenesisState) Validate() error { + // TODO: ??? + return nil +} diff --git a/x/icqoracle/types/genesis.pb.go b/x/icqoracle/types/genesis.pb.go new file mode 100644 index 0000000000..228d5b5b99 --- /dev/null +++ b/x/icqoracle/types/genesis.pb.go @@ -0,0 +1,442 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/icqoracle/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the icqoracle module parameters. +type Params struct { +} + +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_e2938dee39d417bb, []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 + +// GenesisState defines the icqoracle module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_e2938dee39d417bb, []int{1} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*Params)(nil), "stride.icqoracle.Params") + proto.RegisterType((*GenesisState)(nil), "stride.icqoracle.GenesisState") +} + +func init() { proto.RegisterFile("stride/icqoracle/genesis.proto", fileDescriptor_e2938dee39d417bb) } + +var fileDescriptor_e2938dee39d417bb = []byte{ + // 210 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x2e, 0x29, 0xca, + 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x49, 0xcc, 0x4e, 0x2d, 0xc9, 0x4c, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, + 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xeb, 0xc1, 0xa4, + 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x99, 0x12, 0x07, 0x17, + 0x5b, 0x40, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x52, 0x18, 0x17, 0x8f, 0x3b, 0xc4, 0x84, 0xe0, 0x92, + 0xc4, 0x92, 0x54, 0x21, 0x37, 0x2e, 0xb6, 0x02, 0xb0, 0x8c, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, + 0x91, 0xb8, 0x1e, 0x9a, 0x89, 0x7a, 0x10, 0x8d, 0x4e, 0xa2, 0x27, 0xee, 0xc9, 0x33, 0x7c, 0xba, + 0x27, 0xcf, 0x5b, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x04, 0xd1, 0xa4, 0x14, 0x04, 0xd5, 0xed, 0xe4, + 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, + 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, + 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc1, 0x60, 0xb3, 0x75, 0x7d, 0x12, 0x93, 0x8a, 0xf5, + 0xa1, 0x1e, 0x2b, 0x33, 0x34, 0xd7, 0xaf, 0x40, 0x78, 0xaf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, + 0x0d, 0xec, 0x6c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x02, 0xbd, 0x83, 0xfe, 0x00, + 0x00, 0x00, +} + +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 + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(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 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 { + 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 (m *GenesisState) 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 + } + if err := m.Params.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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go new file mode 100644 index 0000000000..5936350673 --- /dev/null +++ b/x/icqoracle/types/keys.go @@ -0,0 +1,8 @@ +package types + +const ( + ModuleName = "icqoracle" + + // StoreKey defines the primary module store key + StoreKey = ModuleName +) diff --git a/x/icqoracle/types/params.go b/x/icqoracle/types/params.go new file mode 100644 index 0000000000..874012a4b8 --- /dev/null +++ b/x/icqoracle/types/params.go @@ -0,0 +1,16 @@ +package types + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} From 76e4c715ade6ee1043e1de37b1af53caff7465ac Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 8 Dec 2024 09:54:02 +0200 Subject: [PATCH 002/115] icqoracle proto --- proto/stride/icqoracle/genesis.proto | 15 +++---- proto/stride/icqoracle/icqoracle.proto | 38 ++++++++++++++++ proto/stride/icqoracle/query.proto | 58 +++++++++++++++++++++++++ proto/stride/icqoracle/tx.proto | 60 ++++++++++++++++++++++++++ 4 files changed, 162 insertions(+), 9 deletions(-) create mode 100644 proto/stride/icqoracle/icqoracle.proto create mode 100644 proto/stride/icqoracle/query.proto create mode 100644 proto/stride/icqoracle/tx.proto diff --git a/proto/stride/icqoracle/genesis.proto b/proto/stride/icqoracle/genesis.proto index 36926e434c..b82dfdf0c6 100644 --- a/proto/stride/icqoracle/genesis.proto +++ b/proto/stride/icqoracle/genesis.proto @@ -2,18 +2,15 @@ syntax = "proto3"; package stride.icqoracle; import "gogoproto/gogo.proto"; +import "stride/icqoracle/icqoracle.proto"; option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; -// Params defines the icqoracle module parameters. -message Params {} - -// GenesisState defines the icqoracle module's genesis state. +// GenesisState defines the icqoracle module's genesis state message GenesisState { - Params params = 1 [ - (gogoproto.moretags) = "yaml:\"params\"", - (gogoproto.nullable) = false - ]; + // Module parameters + Params params = 1 [ (gogoproto.nullable) = false ]; - // TODO: Add data structures + // List of token prices + repeated TokenPrice token_prices = 2 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto new file mode 100644 index 0000000000..f24c09a3b8 --- /dev/null +++ b/proto/stride/icqoracle/icqoracle.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +package stride.icqoracle; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; + +// TokenPrice stores latest price data for a token +message TokenPrice { + // Token denom (e.g. "uatom", "uosmo") + string denom = 1; + + // Price in USDC or STRD + string price = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + // Last update timestamp + google.protobuf.Timestamp updated_at = 3 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; +} + +// OracleParams stores global oracle parameters +message Params { + // Time between price updates + uint64 update_interval_sec = 1 [ + (gogoproto.moretags) = "yaml:\"update_interval_sec\"", + (gogoproto.jsontag) = "update_interval_sec" + ]; + + // Max time before price is stale + uint64 timeout_sec = 2 [ + (gogoproto.moretags) = "yaml:\"timeout_sec\"", + (gogoproto.jsontag) = "timeout_sec" + ]; +} diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto new file mode 100644 index 0000000000..b9bd91edcc --- /dev/null +++ b/proto/stride/icqoracle/query.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; +package stride.icqoracle; + +import "stride/icqoracle/icqoracle.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; + +// Query defines the gRPC querier service. +service Query { + // TokenPrice queries the current price for a specific token + rpc TokenPrice(QueryTokenPriceRequest) returns (QueryTokenPriceResponse) { + option (google.api.http).get = "/stride/icqoracle/v1beta1/price/{denom}"; + } + + // TokenPrices queries all token prices + rpc TokenPrices(QueryTokenPricesRequest) returns (QueryTokenPricesResponse) { + option (google.api.http).get = "/stride/icqoracle/v1beta1/prices"; + } + + // Params queries the oracle parameters + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/stride/icqoracle/v1beta1/params"; + } +} + +// QueryTokenPriceRequest is the request type for the Query/TokenPrice RPC +// method +message QueryTokenPriceRequest { string denom = 1; } + +// QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC +// method +message QueryTokenPriceResponse { + TokenPrice token_price = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryTokenPricesRequest is the request type for the Query/TokenPrices RPC +// method +message QueryTokenPricesRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryTokenPricesResponse is the response type for the Query/TokenPrices RPC +// method +message QueryTokenPricesResponse { + repeated TokenPrice token_prices = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryParamsRequest is the request type for the Query/Params RPC method +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method +message QueryParamsResponse { + Params params = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto new file mode 100644 index 0000000000..1660403ef3 --- /dev/null +++ b/proto/stride/icqoracle/tx.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; +package stride.icqoracle; + +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // UpdateParams allows the admin to update the module parameters + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // AddTokenPrice adds a new token to track prices for + rpc AddTokenPrice(MsgAddTokenPrice) returns (MsgAddTokenPriceResponse); + + // RemoveTokenPrice removes a token from price tracking + rpc RemoveTokenPrice(MsgRemoveTokenPrice) + returns (MsgRemoveTokenPriceResponse); +} + +// MsgUpdateParams defines the message for updating module parameters +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "stride/x/icqoracle/MsgUpdateParams"; + + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // How often to fetch the price + uint64 update_interval_sec = 2; + // When price is considered stale + uint64 timeout_sec = 3; +} + +message MsgUpdateParamsResponse {} + +// MsgAddTokenPrice defines the message for adding a new token to track prices +message MsgAddTokenPrice { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "stride/x/icqoracle/MsgAddTokenPrice"; + + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string denom = 2; +} + +message MsgAddTokenPriceResponse {} + +// MsgRemoveTokenPrice defines the message for removing a token from price +// tracking +message MsgRemoveTokenPrice { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "stride/x/icqoracle/MsgRemoveTokenPrice"; + + string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string denom = 2; +} + +message MsgRemoveTokenPriceResponse {} \ No newline at end of file From 071e6769f599a4a329a65e9951ab56ba4a5d2b2d Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 8 Dec 2024 10:21:41 +0200 Subject: [PATCH 003/115] make proto-all --- x/icqoracle/types/genesis.pb.go | 223 ++--- x/icqoracle/types/icqoracle.pb.go | 629 +++++++++++++ x/icqoracle/types/query.pb.go | 1395 +++++++++++++++++++++++++++++ x/icqoracle/types/query.pb.gw.go | 337 +++++++ x/icqoracle/types/tx.pb.go | 1376 ++++++++++++++++++++++++++++ 5 files changed, 3821 insertions(+), 139 deletions(-) create mode 100644 x/icqoracle/types/icqoracle.pb.go create mode 100644 x/icqoracle/types/query.pb.go create mode 100644 x/icqoracle/types/query.pb.gw.go create mode 100644 x/icqoracle/types/tx.pb.go diff --git a/x/icqoracle/types/genesis.pb.go b/x/icqoracle/types/genesis.pb.go index 228d5b5b99..9ab1a5af1a 100644 --- a/x/icqoracle/types/genesis.pb.go +++ b/x/icqoracle/types/genesis.pb.go @@ -23,53 +23,19 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Params defines the icqoracle module parameters. -type Params struct { -} - -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_e2938dee39d417bb, []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 - -// GenesisState defines the icqoracle module's genesis state. +// GenesisState defines the icqoracle module's genesis state type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` + // Module parameters + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // List of token prices + TokenPrices []TokenPrice `protobuf:"bytes,2,rep,name=token_prices,json=tokenPrices,proto3" json:"token_prices"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_e2938dee39d417bb, []int{1} + return fileDescriptor_a0cfd8712dde4d4a, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -105,52 +71,36 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func init() { - proto.RegisterType((*Params)(nil), "stride.icqoracle.Params") - proto.RegisterType((*GenesisState)(nil), "stride.icqoracle.GenesisState") -} - -func init() { proto.RegisterFile("stride/icqoracle/genesis.proto", fileDescriptor_e2938dee39d417bb) } - -var fileDescriptor_e2938dee39d417bb = []byte{ - // 210 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x2e, 0x29, 0xca, - 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x49, 0xcc, 0x4e, 0x2d, 0xc9, 0x4c, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, - 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x48, 0xeb, 0xc1, 0xa4, - 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x99, 0x12, 0x07, 0x17, - 0x5b, 0x40, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x52, 0x18, 0x17, 0x8f, 0x3b, 0xc4, 0x84, 0xe0, 0x92, - 0xc4, 0x92, 0x54, 0x21, 0x37, 0x2e, 0xb6, 0x02, 0xb0, 0x8c, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, - 0x91, 0xb8, 0x1e, 0x9a, 0x89, 0x7a, 0x10, 0x8d, 0x4e, 0xa2, 0x27, 0xee, 0xc9, 0x33, 0x7c, 0xba, - 0x27, 0xcf, 0x5b, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x04, 0xd1, 0xa4, 0x14, 0x04, 0xd5, 0xed, 0xe4, - 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, - 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, - 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc1, 0x60, 0xb3, 0x75, 0x7d, 0x12, 0x93, 0x8a, 0xf5, - 0xa1, 0x1e, 0x2b, 0x33, 0x34, 0xd7, 0xaf, 0x40, 0x78, 0xaf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, - 0x0d, 0xec, 0x6c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x02, 0xbd, 0x83, 0xfe, 0x00, - 0x00, 0x00, -} - -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 +func (m *GenesisState) GetTokenPrices() []TokenPrice { + if m != nil { + return m.TokenPrices } - return dAtA[:n], nil + return nil } -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func init() { + proto.RegisterType((*GenesisState)(nil), "stride.icqoracle.GenesisState") } -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func init() { proto.RegisterFile("stride/icqoracle/genesis.proto", fileDescriptor_a0cfd8712dde4d4a) } + +var fileDescriptor_a0cfd8712dde4d4a = []byte{ + // 240 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x2e, 0x29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, 0xb0, 0xa1, 0xba, 0x3e, 0x89, 0x49, 0xc5, 0xfa, 0x50, 0x2f, + 0x96, 0x19, 0x99, 0xe8, 0x57, 0x20, 0x79, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, + 0x4b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x21, 0x4a, 0x5a, 0xfa, 0x51, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -173,6 +123,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TokenPrices) > 0 { + for iNdEx := len(m.TokenPrices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokenPrices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -197,15 +161,6 @@ func encodeVarintGenesis(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 - return n -} - func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -214,6 +169,12 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.TokenPrices) > 0 { + for _, e := range m.TokenPrices { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -223,7 +184,7 @@ func sovGenesis(x uint64) (n int) { func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Params) Unmarshal(dAtA []byte) error { +func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -246,65 +207,48 @@ func (m *Params) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis + 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 (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthGenesis } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GenesisState) 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 + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TokenPrices", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -331,7 +275,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TokenPrices = append(m.TokenPrices, TokenPrice{}) + if err := m.TokenPrices[len(m.TokenPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go new file mode 100644 index 0000000000..0488916fb7 --- /dev/null +++ b/x/icqoracle/types/icqoracle.pb.go @@ -0,0 +1,629 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/icqoracle/icqoracle.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/cosmos/gogoproto/types" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + 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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// TokenPrice stores latest price data for a token +type TokenPrice struct { + // Token denom (e.g. "uatom", "uosmo") + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + // Price in USDC or STRD + Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` + // Last update timestamp + UpdatedAt time.Time `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` +} + +func (m *TokenPrice) Reset() { *m = TokenPrice{} } +func (m *TokenPrice) String() string { return proto.CompactTextString(m) } +func (*TokenPrice) ProtoMessage() {} +func (*TokenPrice) Descriptor() ([]byte, []int) { + return fileDescriptor_08ead8ab9516d7fc, []int{0} +} +func (m *TokenPrice) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TokenPrice.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 *TokenPrice) XXX_Merge(src proto.Message) { + xxx_messageInfo_TokenPrice.Merge(m, src) +} +func (m *TokenPrice) XXX_Size() int { + return m.Size() +} +func (m *TokenPrice) XXX_DiscardUnknown() { + xxx_messageInfo_TokenPrice.DiscardUnknown(m) +} + +var xxx_messageInfo_TokenPrice proto.InternalMessageInfo + +func (m *TokenPrice) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *TokenPrice) GetUpdatedAt() time.Time { + if m != nil { + return m.UpdatedAt + } + return time.Time{} +} + +// OracleParams stores global oracle parameters +type Params struct { + // Time between price updates + UpdateIntervalSec uint64 `protobuf:"varint,1,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` + // Max time before price is stale + TimeoutSec uint64 `protobuf:"varint,2,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec" yaml:"timeout_sec"` +} + +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_08ead8ab9516d7fc, []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) GetUpdateIntervalSec() uint64 { + if m != nil { + return m.UpdateIntervalSec + } + return 0 +} + +func (m *Params) GetTimeoutSec() uint64 { + if m != nil { + return m.TimeoutSec + } + return 0 +} + +func init() { + proto.RegisterType((*TokenPrice)(nil), "stride.icqoracle.TokenPrice") + proto.RegisterType((*Params)(nil), "stride.icqoracle.Params") +} + +func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } + +var fileDescriptor_08ead8ab9516d7fc = []byte{ + // 387 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xb1, 0xae, 0xd3, 0x30, + 0x14, 0x86, 0xe3, 0x0b, 0xf7, 0x8a, 0xeb, 0x2e, 0x10, 0x3a, 0x54, 0x41, 0x8a, 0xab, 0x20, 0xa4, + 0x2e, 0xd8, 0x52, 0x0b, 0x03, 0x6c, 0x04, 0x84, 0x84, 0x54, 0xa4, 0x2a, 0xed, 0xc4, 0x52, 0x39, + 0x8e, 0x49, 0xa3, 0xc6, 0x75, 0x88, 0x9d, 0x8a, 0xbe, 0x45, 0x9f, 0x81, 0x97, 0xe0, 0x15, 0x3a, + 0x76, 0x44, 0x0c, 0x01, 0xb5, 0x5b, 0xc7, 0x3e, 0x01, 0x4a, 0x9c, 0xa2, 0x0c,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ce, 0x15, 0x67, 0x75, 0xdc, 0x87, 0xfe, 0xeb, 0x53, 0x89, 0xae, 0xc9, 0xe7, 0x12, + 0x39, 0x1b, 0x2a, 0xd2, 0xb7, 0xde, 0x15, 0xd1, 0x0b, 0x9e, 0x18, 0xfa, 0xa9, 0x81, 0x53, 0xce, + 0xec, 0x8f, 0xb0, 0x53, 0x6d, 0x4a, 0x16, 0xba, 0xb6, 0xbf, 0xa9, 0xed, 0x5f, 0x9c, 0x4a, 0xd4, + 0xc6, 0xe7, 0x12, 0xd9, 0xc6, 0xb6, 0x05, 0xbd, 0x00, 0x36, 0xd5, 0x94, 0x33, 0xff, 0xf3, 0xee, + 0xe0, 0x82, 0xfd, 0xc1, 0x05, 0x7f, 0x0f, 0x2e, 0xd8, 0x1e, 0x5d, 0x6b, 0x7f, 0x74, 0xad, 0x5f, + 0x47, 0xd7, 0xfa, 0x32, 0x8a, 0x13, 0xbd, 0x28, 0x42, 0xcc, 0xa4, 0x20, 0xd3, 0xfa, 0x98, 0x2f, + 0xc7, 0x34, 0x54, 0xa4, 0x39, 0xfd, 0x7a, 0xf8, 0x8a, 0x7c, 0x6f, 0x7d, 0x00, 0xbd, 0xc9, 0xb8, + 0x0a, 0xef, 0xea, 0x8d, 0x8d, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x2c, 0x54, 0xd4, 0x21, + 0x02, 0x00, 0x00, +} + +func (m *TokenPrice) 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 *TokenPrice) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintIcqoracle(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x1a + { + size := m.Price.Size() + i -= size + if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintIcqoracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + 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 m.TimeoutSec != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.TimeoutSec)) + i-- + dAtA[i] = 0x10 + } + if m.UpdateIntervalSec != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.UpdateIntervalSec)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintIcqoracle(dAtA []byte, offset int, v uint64) int { + offset -= sovIcqoracle(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *TokenPrice) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } + l = m.Price.Size() + n += 1 + l + sovIcqoracle(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) + n += 1 + l + sovIcqoracle(uint64(l)) + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.UpdateIntervalSec != 0 { + n += 1 + sovIcqoracle(uint64(m.UpdateIntervalSec)) + } + if m.TimeoutSec != 0 { + n += 1 + sovIcqoracle(uint64(m.TimeoutSec)) + } + return n +} + +func sovIcqoracle(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozIcqoracle(x uint64) (n int) { + return sovIcqoracle(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TokenPrice) 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 ErrIntOverflowIcqoracle + } + 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: TokenPrice: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = 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 ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipIcqoracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIcqoracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + 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 ErrIntOverflowIcqoracle + } + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateIntervalSec", wireType) + } + m.UpdateIntervalSec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateIntervalSec |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutSec", wireType) + } + m.TimeoutSec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutSec |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipIcqoracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIcqoracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipIcqoracle(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthIcqoracle + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupIcqoracle + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthIcqoracle + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthIcqoracle = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowIcqoracle = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupIcqoracle = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go new file mode 100644 index 0000000000..1685e834d4 --- /dev/null +++ b/x/icqoracle/types/query.pb.go @@ -0,0 +1,1395 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/icqoracle/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryTokenPriceRequest is the request type for the Query/TokenPrice RPC +// method +type QueryTokenPriceRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryTokenPriceRequest) Reset() { *m = QueryTokenPriceRequest{} } +func (m *QueryTokenPriceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTokenPriceRequest) ProtoMessage() {} +func (*QueryTokenPriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{0} +} +func (m *QueryTokenPriceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTokenPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTokenPriceRequest.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 *QueryTokenPriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTokenPriceRequest.Merge(m, src) +} +func (m *QueryTokenPriceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTokenPriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTokenPriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTokenPriceRequest proto.InternalMessageInfo + +func (m *QueryTokenPriceRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC +// method +type QueryTokenPriceResponse struct { + TokenPrice TokenPrice `protobuf:"bytes,1,opt,name=token_price,json=tokenPrice,proto3" json:"token_price"` +} + +func (m *QueryTokenPriceResponse) Reset() { *m = QueryTokenPriceResponse{} } +func (m *QueryTokenPriceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTokenPriceResponse) ProtoMessage() {} +func (*QueryTokenPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{1} +} +func (m *QueryTokenPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTokenPriceResponse.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 *QueryTokenPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTokenPriceResponse.Merge(m, src) +} +func (m *QueryTokenPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTokenPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTokenPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTokenPriceResponse proto.InternalMessageInfo + +func (m *QueryTokenPriceResponse) GetTokenPrice() TokenPrice { + if m != nil { + return m.TokenPrice + } + return TokenPrice{} +} + +// QueryTokenPricesRequest is the request type for the Query/TokenPrices RPC +// method +type QueryTokenPricesRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryTokenPricesRequest) Reset() { *m = QueryTokenPricesRequest{} } +func (m *QueryTokenPricesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTokenPricesRequest) ProtoMessage() {} +func (*QueryTokenPricesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{2} +} +func (m *QueryTokenPricesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTokenPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTokenPricesRequest.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 *QueryTokenPricesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTokenPricesRequest.Merge(m, src) +} +func (m *QueryTokenPricesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTokenPricesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTokenPricesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTokenPricesRequest proto.InternalMessageInfo + +func (m *QueryTokenPricesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryTokenPricesResponse is the response type for the Query/TokenPrices RPC +// method +type QueryTokenPricesResponse struct { + TokenPrices []TokenPrice `protobuf:"bytes,1,rep,name=token_prices,json=tokenPrices,proto3" json:"token_prices"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryTokenPricesResponse) Reset() { *m = QueryTokenPricesResponse{} } +func (m *QueryTokenPricesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTokenPricesResponse) ProtoMessage() {} +func (*QueryTokenPricesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{3} +} +func (m *QueryTokenPricesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTokenPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTokenPricesResponse.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 *QueryTokenPricesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTokenPricesResponse.Merge(m, src) +} +func (m *QueryTokenPricesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTokenPricesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTokenPricesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTokenPricesResponse proto.InternalMessageInfo + +func (m *QueryTokenPricesResponse) GetTokenPrices() []TokenPrice { + if m != nil { + return m.TokenPrices + } + return nil +} + +func (m *QueryTokenPricesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryParamsRequest is the request type for the Query/Params RPC method +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{4} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{5} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryTokenPriceRequest)(nil), "stride.icqoracle.QueryTokenPriceRequest") + proto.RegisterType((*QueryTokenPriceResponse)(nil), "stride.icqoracle.QueryTokenPriceResponse") + proto.RegisterType((*QueryTokenPricesRequest)(nil), "stride.icqoracle.QueryTokenPricesRequest") + proto.RegisterType((*QueryTokenPricesResponse)(nil), "stride.icqoracle.QueryTokenPricesResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "stride.icqoracle.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "stride.icqoracle.QueryParamsResponse") +} + +func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } + +var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x8a, 0xd3, 0x40,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, 0x9a, 0x35, 0xd0, 0xb7, 0x7a, + 0xe5, 0xde, 0xe1, 0x8f, 0x08, 0x3a, 0xa5, 0xb7, 0xc2, 0xcd, 0xdf, 0xca, 0x07, 0xe5, 0xec, 0xae, + 0x23, 0xb5, 0x5c, 0x43, 0xcd, 0xe5, 0xe1, 0x41, 0x03, 0x97, 0xc4, 0xef, 0xa1, 0x6d, 0xe6, 0x88, + 0x6f, 0xfc, 0xc7, 0xbf, 0xf2, 0x5c, 0xce, 0xcd, 0x06, 0xd5, 0x39, 0x00, 0xcc, 0xf3, 0x1d, 0x9c, + 0x2e, 0x5c, 0x74, 0xb6, 0x70, 0xd1, 0xaf, 0x85, 0x8b, 0x3e, 0x2d, 0xdd, 0xd6, 0xd9, 0xd2, 0x6d, + 0xfd, 0x58, 0xba, 0xad, 0xe7, 0xfb, 0x61, 0xa4, 0x5e, 0xcd, 0x7d, 0x12, 0x88, 0x29, 0x7d, 0xaa, + 0x5d, 0x6e, 0x3f, 0x66, 0xbe, 0xcc, 0x1d, 0x8f, 0x47, 0x77, 0xe8, 0x9b, 0x92, 0xaf, 0x3a, 0x49, + 0xb8, 0xf4, 0xdb, 0xfa, 0xbf, 0x60, 0xff, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x87, 0x3f, 0xe0, + 0xb9, 0xbf, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // TokenPrice queries the current price for a specific token + TokenPrice(ctx context.Context, in *QueryTokenPriceRequest, opts ...grpc.CallOption) (*QueryTokenPriceResponse, error) + // TokenPrices queries all token prices + TokenPrices(ctx context.Context, in *QueryTokenPricesRequest, opts ...grpc.CallOption) (*QueryTokenPricesResponse, error) + // Params queries the oracle parameters + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) TokenPrice(ctx context.Context, in *QueryTokenPriceRequest, opts ...grpc.CallOption) (*QueryTokenPriceResponse, error) { + out := new(QueryTokenPriceResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Query/TokenPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TokenPrices(ctx context.Context, in *QueryTokenPricesRequest, opts ...grpc.CallOption) (*QueryTokenPricesResponse, error) { + out := new(QueryTokenPricesResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Query/TokenPrices", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // TokenPrice queries the current price for a specific token + TokenPrice(context.Context, *QueryTokenPriceRequest) (*QueryTokenPriceResponse, error) + // TokenPrices queries all token prices + TokenPrices(context.Context, *QueryTokenPricesRequest) (*QueryTokenPricesResponse, error) + // Params queries the oracle parameters + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) TokenPrice(ctx context.Context, req *QueryTokenPriceRequest) (*QueryTokenPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TokenPrice not implemented") +} +func (*UnimplementedQueryServer) TokenPrices(ctx context.Context, req *QueryTokenPricesRequest) (*QueryTokenPricesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TokenPrices not implemented") +} +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_TokenPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTokenPriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TokenPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Query/TokenPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TokenPrice(ctx, req.(*QueryTokenPriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TokenPrices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTokenPricesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TokenPrices(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Query/TokenPrices", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TokenPrices(ctx, req.(*QueryTokenPricesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "stride.icqoracle.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "TokenPrice", + Handler: _Query_TokenPrice_Handler, + }, + { + MethodName: "TokenPrices", + Handler: _Query_TokenPrices_Handler, + }, + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "stride/icqoracle/query.proto", +} + +func (m *QueryTokenPriceRequest) 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 *QueryTokenPriceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTokenPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTokenPriceResponse) 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 *QueryTokenPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.TokenPrice.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTokenPricesRequest) 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 *QueryTokenPricesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTokenPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTokenPricesResponse) 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 *QueryTokenPricesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTokenPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.TokenPrices) > 0 { + for iNdEx := len(m.TokenPrices) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokenPrices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryTokenPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTokenPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TokenPrice.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTokenPricesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTokenPricesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TokenPrices) > 0 { + for _, e := range m.TokenPrices { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryTokenPriceRequest) 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: QueryTokenPriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTokenPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + 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 *QueryTokenPriceResponse) 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: QueryTokenPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTokenPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenPrice", 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 := m.TokenPrice.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 (m *QueryTokenPricesRequest) 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: QueryTokenPricesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTokenPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryTokenPricesResponse) 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: QueryTokenPricesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTokenPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenPrices", 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 + } + m.TokenPrices = append(m.TokenPrices, TokenPrice{}) + if err := m.TokenPrices[len(m.TokenPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 := m.Params.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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/icqoracle/types/query.pb.gw.go b/x/icqoracle/types/query.pb.gw.go new file mode 100644 index 0000000000..091e66b3c8 --- /dev/null +++ b/x/icqoracle/types/query.pb.gw.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: stride/icqoracle/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_TokenPrice_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTokenPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.TokenPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TokenPrice_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTokenPriceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.TokenPrice(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_TokenPrices_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_TokenPrices_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTokenPricesRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TokenPrices_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TokenPrices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TokenPrices_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTokenPricesRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TokenPrices_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TokenPrices(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_TokenPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TokenPrice_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TokenPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TokenPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TokenPrices_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TokenPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_TokenPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TokenPrice_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TokenPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TokenPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TokenPrices_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TokenPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"stride", "icqoracle", "v1beta1", "price", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_TokenPrice_0 = runtime.ForwardResponseMessage + + forward_Query_TokenPrices_0 = runtime.ForwardResponseMessage + + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go new file mode 100644 index 0000000000..e076bc86d8 --- /dev/null +++ b/x/icqoracle/types/tx.pb.go @@ -0,0 +1,1376 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/icqoracle/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateParams defines the message for updating module parameters +type MsgUpdateParams struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // How often to fetch the price + UpdateIntervalSec uint64 `protobuf:"varint,2,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec,omitempty"` + // When price is considered stale + TimeoutSec uint64 `protobuf:"varint,3,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec,omitempty"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_be640eb75c1babd5, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgUpdateParams) GetUpdateIntervalSec() uint64 { + if m != nil { + return m.UpdateIntervalSec + } + return 0 +} + +func (m *MsgUpdateParams) GetTimeoutSec() uint64 { + if m != nil { + return m.TimeoutSec + } + return 0 +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_be640eb75c1babd5, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +// MsgAddTokenPrice defines the message for adding a new token to track prices +type MsgAddTokenPrice struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *MsgAddTokenPrice) Reset() { *m = MsgAddTokenPrice{} } +func (m *MsgAddTokenPrice) String() string { return proto.CompactTextString(m) } +func (*MsgAddTokenPrice) ProtoMessage() {} +func (*MsgAddTokenPrice) Descriptor() ([]byte, []int) { + return fileDescriptor_be640eb75c1babd5, []int{2} +} +func (m *MsgAddTokenPrice) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddTokenPrice.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 *MsgAddTokenPrice) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddTokenPrice.Merge(m, src) +} +func (m *MsgAddTokenPrice) XXX_Size() int { + return m.Size() +} +func (m *MsgAddTokenPrice) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddTokenPrice.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddTokenPrice proto.InternalMessageInfo + +func (m *MsgAddTokenPrice) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgAddTokenPrice) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type MsgAddTokenPriceResponse struct { +} + +func (m *MsgAddTokenPriceResponse) Reset() { *m = MsgAddTokenPriceResponse{} } +func (m *MsgAddTokenPriceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddTokenPriceResponse) ProtoMessage() {} +func (*MsgAddTokenPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_be640eb75c1babd5, []int{3} +} +func (m *MsgAddTokenPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddTokenPriceResponse.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 *MsgAddTokenPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddTokenPriceResponse.Merge(m, src) +} +func (m *MsgAddTokenPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddTokenPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddTokenPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddTokenPriceResponse proto.InternalMessageInfo + +// MsgRemoveTokenPrice defines the message for removing a token from price +// tracking +type MsgRemoveTokenPrice struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *MsgRemoveTokenPrice) Reset() { *m = MsgRemoveTokenPrice{} } +func (m *MsgRemoveTokenPrice) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveTokenPrice) ProtoMessage() {} +func (*MsgRemoveTokenPrice) Descriptor() ([]byte, []int) { + return fileDescriptor_be640eb75c1babd5, []int{4} +} +func (m *MsgRemoveTokenPrice) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveTokenPrice.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 *MsgRemoveTokenPrice) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveTokenPrice.Merge(m, src) +} +func (m *MsgRemoveTokenPrice) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveTokenPrice) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveTokenPrice.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveTokenPrice proto.InternalMessageInfo + +func (m *MsgRemoveTokenPrice) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgRemoveTokenPrice) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type MsgRemoveTokenPriceResponse struct { +} + +func (m *MsgRemoveTokenPriceResponse) Reset() { *m = MsgRemoveTokenPriceResponse{} } +func (m *MsgRemoveTokenPriceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveTokenPriceResponse) ProtoMessage() {} +func (*MsgRemoveTokenPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_be640eb75c1babd5, []int{5} +} +func (m *MsgRemoveTokenPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveTokenPriceResponse.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 *MsgRemoveTokenPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveTokenPriceResponse.Merge(m, src) +} +func (m *MsgRemoveTokenPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveTokenPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveTokenPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveTokenPriceResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "stride.icqoracle.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "stride.icqoracle.MsgUpdateParamsResponse") + proto.RegisterType((*MsgAddTokenPrice)(nil), "stride.icqoracle.MsgAddTokenPrice") + proto.RegisterType((*MsgAddTokenPriceResponse)(nil), "stride.icqoracle.MsgAddTokenPriceResponse") + proto.RegisterType((*MsgRemoveTokenPrice)(nil), "stride.icqoracle.MsgRemoveTokenPrice") + proto.RegisterType((*MsgRemoveTokenPriceResponse)(nil), "stride.icqoracle.MsgRemoveTokenPriceResponse") +} + +func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } + +var fileDescriptor_be640eb75c1babd5 = []byte{ + // 488 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x41, 0x8b, 0xd3, 0x50, + 0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x45, 0xeb, 0xc2, 0xf5, + 0xfc, 0x1a, 0xcd, 0xd2, 0xde, 0x1c, 0xa3, 0x37, 0x57, 0x33, 0x4b, 0x81, 0x3e, 0xd4, 0xfe, 0x9a, + 0xfc, 0xbd, 0xd2, 0xfe, 0x22, 0xa6, 0xb7, 0xfe, 0x09, 0x5b, 0x28, 0xe9, 0x1b, 0xef, 0x66, 0xe3, + 0x26, 0x3b, 0x76, 0xbe, 0x4d, 0x0c, 0x76, 0x31, 0x31, 0xd8, 0xaf, 0x89, 0xc1, 0x3e, 0x4d, 0x8d, + 0xca, 0xc5, 0xd4, 0xa8, 0xfc, 0x9c, 0x1a, 0x95, 0x57, 0xed, 0x90, 0xab, 0xfe, 0xb0, 0x67, 0xf9, + 0x22, 0xb2, 0x3b, 0xc9, 0xc9, 0xad, 0xe7, 0x5e, 0x8f, 0xec, 0x6c, 0x5f, 0xa3, 0x83, 0xc7, 0xb9, + 0x9d, 0xa9, 0xf3, 0x01, 0x52, 0x6f, 0x33, 0xf9, 0xb6, 0xdb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, + 0xc0, 0x38, 0xbd, 0xc7, 0x51, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UpdateParams allows the admin to update the module parameters + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // AddTokenPrice adds a new token to track prices for + AddTokenPrice(ctx context.Context, in *MsgAddTokenPrice, opts ...grpc.CallOption) (*MsgAddTokenPriceResponse, error) + // RemoveTokenPrice removes a token from price tracking + RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPrice, opts ...grpc.CallOption) (*MsgRemoveTokenPriceResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) AddTokenPrice(ctx context.Context, in *MsgAddTokenPrice, opts ...grpc.CallOption) (*MsgAddTokenPriceResponse, error) { + out := new(MsgAddTokenPriceResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/AddTokenPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPrice, opts ...grpc.CallOption) (*MsgRemoveTokenPriceResponse, error) { + out := new(MsgRemoveTokenPriceResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/RemoveTokenPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateParams allows the admin to update the module parameters + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // AddTokenPrice adds a new token to track prices for + AddTokenPrice(context.Context, *MsgAddTokenPrice) (*MsgAddTokenPriceResponse, error) + // RemoveTokenPrice removes a token from price tracking + RemoveTokenPrice(context.Context, *MsgRemoveTokenPrice) (*MsgRemoveTokenPriceResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) AddTokenPrice(ctx context.Context, req *MsgAddTokenPrice) (*MsgAddTokenPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddTokenPrice not implemented") +} +func (*UnimplementedMsgServer) RemoveTokenPrice(ctx context.Context, req *MsgRemoveTokenPrice) (*MsgRemoveTokenPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveTokenPrice not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_AddTokenPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddTokenPrice) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddTokenPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Msg/AddTokenPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddTokenPrice(ctx, req.(*MsgAddTokenPrice)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RemoveTokenPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveTokenPrice) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveTokenPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Msg/RemoveTokenPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveTokenPrice(ctx, req.(*MsgRemoveTokenPrice)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "stride.icqoracle.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "AddTokenPrice", + Handler: _Msg_AddTokenPrice_Handler, + }, + { + MethodName: "RemoveTokenPrice", + Handler: _Msg_RemoveTokenPrice_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "stride/icqoracle/tx.proto", +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TimeoutSec != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TimeoutSec)) + i-- + dAtA[i] = 0x18 + } + if m.UpdateIntervalSec != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.UpdateIntervalSec)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgAddTokenPrice) 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 *MsgAddTokenPrice) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddTokenPriceResponse) 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 *MsgAddTokenPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddTokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRemoveTokenPrice) 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 *MsgRemoveTokenPrice) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveTokenPriceResponse) 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 *MsgRemoveTokenPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveTokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.UpdateIntervalSec != 0 { + n += 1 + sovTx(uint64(m.UpdateIntervalSec)) + } + if m.TimeoutSec != 0 { + n += 1 + sovTx(uint64(m.TimeoutSec)) + } + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgAddTokenPrice) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAddTokenPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRemoveTokenPrice) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRemoveTokenPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateIntervalSec", wireType) + } + m.UpdateIntervalSec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateIntervalSec |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutSec", wireType) + } + m.TimeoutSec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutSec |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddTokenPrice) 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 ErrIntOverflowTx + } + 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: MsgAddTokenPrice: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddTokenPriceResponse) 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 ErrIntOverflowTx + } + 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: MsgAddTokenPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddTokenPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveTokenPrice) 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 ErrIntOverflowTx + } + 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: MsgRemoveTokenPrice: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveTokenPriceResponse) 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 ErrIntOverflowTx + } + 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: MsgRemoveTokenPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveTokenPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 62c093e32bc45441e94dc10d298dd1fb28be2167 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 10 Dec 2024 11:13:48 +0200 Subject: [PATCH 004/115] boilerplate for x/icqoracle --- proto/stride/icqoracle/icqoracle.proto | 25 +- proto/stride/icqoracle/query.proto | 8 +- proto/stride/icqoracle/tx.proto | 27 +- utils/utils.go | 27 ++ x/icqoracle/client/cli/query.go | 104 +++++ x/icqoracle/client/cli/tx.go | 106 +++++ x/icqoracle/keeper/abci.go | 7 +- x/icqoracle/keeper/genesis.go | 12 +- x/icqoracle/keeper/keeper.go | 127 ++++++ x/icqoracle/keeper/msg_server.go | 55 +++ x/icqoracle/keeper/params.go | 25 ++ x/icqoracle/keeper/query.go | 62 +++ x/icqoracle/types/icqoracle.pb.go | 254 +++++++++-- x/icqoracle/types/keys.go | 7 + x/icqoracle/types/msgs.go | 118 ++++++ x/icqoracle/types/query.pb.go | 139 +++++-- x/icqoracle/types/query.pb.gw.go | 40 +- x/icqoracle/types/tx.pb.go | 556 ++++++------------------- 18 files changed, 1141 insertions(+), 558 deletions(-) create mode 100644 x/icqoracle/client/cli/query.go create mode 100644 x/icqoracle/client/cli/tx.go create mode 100644 x/icqoracle/keeper/msg_server.go create mode 100644 x/icqoracle/keeper/params.go create mode 100644 x/icqoracle/keeper/query.go create mode 100644 x/icqoracle/types/msgs.go diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index f24c09a3b8..34d7f03406 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -9,29 +9,44 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; // TokenPrice stores latest price data for a token message TokenPrice { // Token denom (e.g. "uatom", "uosmo") - string denom = 1; + string base_denom = 1; + + // Quote denom (e.g. ustrd, uusdc) + string quote_denom = 2; // Price in USDC or STRD - string price = 2 [ + string price = 3 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Last update timestamp - google.protobuf.Timestamp updated_at = 3 + google.protobuf.Timestamp updated_at = 4 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; } // OracleParams stores global oracle parameters message Params { + // Osmosis chain identifier + string osmosis_chain_id = 1 [ + (gogoproto.moretags) = "yaml:\"osmosis_chain_id\"", + (gogoproto.jsontag) = "osmosis_chain_id" + ]; + + // Osmosis IBC connection identifier + string osmosis_connection_id = 2 [ + (gogoproto.moretags) = "yaml:\"osmosis_connection_id\"", + (gogoproto.jsontag) = "osmosis_connection_id" + ]; + // Time between price updates - uint64 update_interval_sec = 1 [ + uint64 update_interval_sec = 3 [ (gogoproto.moretags) = "yaml:\"update_interval_sec\"", (gogoproto.jsontag) = "update_interval_sec" ]; // Max time before price is stale - uint64 timeout_sec = 2 [ + uint64 timeout_sec = 4 [ (gogoproto.moretags) = "yaml:\"timeout_sec\"", (gogoproto.jsontag) = "timeout_sec" ]; diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index b9bd91edcc..f782466370 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -12,7 +12,8 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Query { // TokenPrice queries the current price for a specific token rpc TokenPrice(QueryTokenPriceRequest) returns (QueryTokenPriceResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/price/{denom}"; + option (google.api.http).get = + "/stride/icqoracle/v1beta1/price/{quote_denom}/{base_denom}"; } // TokenPrices queries all token prices @@ -28,7 +29,10 @@ service Query { // QueryTokenPriceRequest is the request type for the Query/TokenPrice RPC // method -message QueryTokenPriceRequest { string denom = 1; } +message QueryTokenPriceRequest { + string base_denom = 1; + string quote_denom = 2; +} // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC // method diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 1660403ef3..2b5cd17730 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -11,9 +11,6 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Msg { option (cosmos.msg.v1.service) = true; - // UpdateParams allows the admin to update the module parameters - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); - // AddTokenPrice adds a new token to track prices for rpc AddTokenPrice(MsgAddTokenPrice) returns (MsgAddTokenPriceResponse); @@ -22,27 +19,16 @@ service Msg { returns (MsgRemoveTokenPriceResponse); } -// MsgUpdateParams defines the message for updating module parameters -message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "stride/x/icqoracle/MsgUpdateParams"; - - string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // How often to fetch the price - uint64 update_interval_sec = 2; - // When price is considered stale - uint64 timeout_sec = 3; -} - -message MsgUpdateParamsResponse {} - // MsgAddTokenPrice defines the message for adding a new token to track prices message MsgAddTokenPrice { option (cosmos.msg.v1.signer) = "sender"; option (amino.name) = "stride/x/icqoracle/MsgAddTokenPrice"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - string denom = 2; + // Token denom (e.g. "uatom", "uosmo") + string base_denom = 2; + // Quote denom (e.g. ustrd, uusdc) + string quote_denom = 3; } message MsgAddTokenPriceResponse {} @@ -54,7 +40,10 @@ message MsgRemoveTokenPrice { option (amino.name) = "stride/x/icqoracle/MsgRemoveTokenPrice"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - string denom = 2; + // Token denom (e.g. "uatom", "uosmo") + string base_denom = 2; + // Quote denom (e.g. ustrd, uusdc) + string quote_denom = 3; } message MsgRemoveTokenPriceResponse {} \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index 0a39951603..2589d84397 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -229,6 +229,25 @@ func LogWithHostZone(chainId string, s string, a ...any) string { return fmt.Sprintf("| %-13s | %s", strings.ToUpper(chainId), msg) } +// Returns a log string with a base denom, quote denom and tab as the prefix +// Ex: +// +// | uosmo/ustrd | string +func LogWithPriceToken(baseDenom string, quoteDenom string, s string, a ...any) string { + msg := fmt.Sprintf(s, a...) + return fmt.Sprintf("| %-13s | %s/%s", baseDenom, quoteDenom, msg) +} + +// Returns a log string with a chain Id and callback as a prefix +// callbackType is either ICACALLBACK or ICQCALLBACK +// Format: +// +// | uosmo/ustrd | {CALLBACK_ID} {CALLBACK_TYPE} | string +func logCallbackWithPriceToken(baseDenom string, quoteDenom string, callbackId string, callbackType string, s string, a ...any) string { + msg := fmt.Sprintf(s, a...) + return fmt.Sprintf("| %s/%s | %s %s | %s", baseDenom, quoteDenom, strings.ToUpper(callbackId), callbackType, msg) +} + // Returns a log string with a chain Id and callback as a prefix // callbackType is either ICACALLBACK or ICQCALLBACK // Format: @@ -272,6 +291,14 @@ func LogICQCallbackWithHostZone(chainId string, callbackId string, s string, a . return logCallbackWithHostZone(chainId, callbackId, "ICQCALLBACK", s, a...) } +// Returns a log string with a chain Id and icqcallback as a prefix +// Ex: +// +// | COSMOSHUB-4 | WITHDRAWALHOSTBALANCE ICQCALLBACK | string +func LogICQCallbackWithPriceToken(baseDenom string, quoteDenom string, callbackId string, s string, a ...any) string { + return logCallbackWithPriceToken(baseDenom, quoteDenom, callbackId, "ICQCALLBACK", s, a...) +} + // Returns a log header string with a dash padding on either side // Ex: // diff --git a/x/icqoracle/client/cli/query.go b/x/icqoracle/client/cli/query.go new file mode 100644 index 0000000000..d1c2356893 --- /dev/null +++ b/x/icqoracle/client/cli/query.go @@ -0,0 +1,104 @@ +package cli + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdQueryTokenPrice(), + CmdQueryTokenPrices(), + CmdQueryParams(), + ) + + return cmd +} + +func CmdQueryTokenPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "token-price [base-denom] [quote-denom]", + Short: "Query the current price for a specific token", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + baseDenom := args[0] + quoteDenom := args[1] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryTokenPriceRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + res, err := queryClient.TokenPrice(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} + +func CmdQueryTokenPrices() *cobra.Command { + cmd := &cobra.Command{ + Use: "token-prices", + Short: "Query all token prices", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryTokenPricesRequest{} + res, err := queryClient.TokenPrices(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Get the parameters", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryParamsRequest{} + res, err := queryClient.Params(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go new file mode 100644 index 0000000000..5f19e2ca46 --- /dev/null +++ b/x/icqoracle/client/cli/tx.go @@ -0,0 +1,106 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdAddTokenPrice(), + CmdRemoveTokenPrice(), + ) + + return cmd +} + +func CmdAddTokenPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-token-price [base-denom] [quote-denom]", + Short: "Add a token to price tracking", + Long: strings.TrimSpace( + fmt.Sprintf(`Add a token to price tracking. + +Example: + $ %[1]s tx %[2]s add-token-price uatom uusdc --from admin +`, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgAddTokenPrice( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdRemoveTokenPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove-token-price [base-denom] [quote-denom]", + Short: "Remove a token from price tracking", + Long: strings.TrimSpace( + fmt.Sprintf(`Remove a token from price tracking. + +Example: + $ %[1]s tx %[2]s remove-token-price uatom uusdc --from admin +`, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRemoveTokenPrice( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index a1b817e17a..daa56e7914 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -1,5 +1,8 @@ package keeper -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) -func (k Keeper) BeginBlocker(ctx sdk.Context) {} +func (k Keeper) BeginBlocker(ctx sdk.Context) { +} diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go index d6e5c3217d..8711a0ca71 100644 --- a/x/icqoracle/keeper/genesis.go +++ b/x/icqoracle/keeper/genesis.go @@ -6,14 +6,18 @@ import ( "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) -// Initializes the genesis state in the store +// Loads module state from genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - // TODO: InitGenesis + k.SetParams(ctx, genState.Params) + for _, tokenPrice := range genState.TokenPrices { + k.SetTokenPrice(ctx, tokenPrice) + } } -// Exports the current state +// Export's module state into genesis file func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genesis := types.DefaultGenesis() - // TODO: InitGenesis + genesis.Params = k.GetParams(ctx) + genesis.TokenPrices = k.GetAllTokenPrices(ctx) return genesis } diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 4282048a1d..6295a426e5 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -1,8 +1,17 @@ package keeper import ( + "encoding/binary" + "fmt" + "time" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + interchainquerykeeper "github.com/Stride-Labs/stride/v24/x/interchainquery/keeper" "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) @@ -12,6 +21,7 @@ type Keeper struct { storeKey storetypes.StoreKey bankKeeper types.BankKeeper transferKeeper types.TransferKeeper + icqKeeper interchainquerykeeper.Keeper } func NewKeeper( @@ -27,3 +37,120 @@ func NewKeeper( transferKeeper: transferKeeper, } } + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// SetLastUpdateTime stores the last time prices were updated +func (k Keeper) SetLastUpdateTime(ctx sdk.Context, timestamp time.Time) { + store := ctx.KVStore(k.storeKey) + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(ctx.BlockTime().UnixNano())) + store.Set([]byte(types.KeyLastUpdateTime), bz) +} + +// GetLastUpdateTime retrieves the last time prices were updated +func (k Keeper) GetLastUpdateTime(ctx sdk.Context) (time.Time, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get([]byte(types.KeyLastUpdateTime)) + if bz == nil { + return time.Time{}, fmt.Errorf("last update time not found") + } + nanos := int64(binary.BigEndian.Uint64(bz)) + return time.Unix(0, nanos), nil +} + +// UpdatePrices queries and updates all token prices +func (k Keeper) UpdatePrices(ctx sdk.Context) error { + // Query prices from Osmosis via ICQ + prices, err := k.QueryOsmosisPrices(ctx) + if err != nil { + return err + } + + // Update stored prices + for _, price := range prices { + if err := k.SetTokenPrice(ctx, price); err != nil { + return err + } + } + + return nil +} + +// SetTokenPrice stores price data for a token +func (k Keeper) SetTokenPrice(ctx sdk.Context, price types.TokenPrice) error { + store := ctx.KVStore(k.storeKey) + key := []byte(fmt.Sprintf("%s/%s/%s", types.KeyPricePrefix, price.BaseDenom, price.QuoteDenom)) + + bz, err := k.cdc.Marshal(&price) + if err != nil { + return err + } + + store.Set(key, bz) + return nil +} + +// RemoveTokenPrice removes price data for a token +func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string) { + store := ctx.KVStore(k.storeKey) + key := []byte(fmt.Sprintf("%s/%s/%s", types.KeyPricePrefix, baseDenom, quoteDenom)) + store.Delete(key) +} + +// GetTokenPrice retrieves price data for a token +func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string) (types.TokenPrice, error) { + store := ctx.KVStore(k.storeKey) + key := []byte(fmt.Sprintf("%s/%s/%s", types.KeyPricePrefix, baseDenom, quoteDenom)) + + bz := store.Get(key) + if bz == nil { + return types.TokenPrice{}, fmt.Errorf("price not found for base denom '%s' & quote denom '%s'", baseDenom, quoteDenom) + } + + var price types.TokenPrice + if err := k.cdc.Unmarshal(bz, &price); err != nil { + return types.TokenPrice{}, err + } + + return price, nil +} + +// GetAllTokenPrices retrieves all stored token prices +func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyPricePrefix)) + defer iterator.Close() + + prices := []types.TokenPrice{} + for ; iterator.Valid(); iterator.Next() { + var price types.TokenPrice + k.cdc.MustUnmarshal(iterator.Value(), &price) + prices = append(prices, price) + } + + return prices +} + +// QueryOsmosisPrices implements the ICQ price query +func (k Keeper) QueryOsmosisPrices(ctx sdk.Context) ([]types.TokenPrice, error) { + // TODO: Implement actual ICQ query to Osmosis + // This is a placeholder that returns mock data + mockPrices := []types.TokenPrice{ + { + BaseDenom: "uatom", + QuoteDenom: "ustrd", + Price: sdk.NewDec(10), + UpdatedAt: ctx.BlockTime(), + }, + { + BaseDenom: "uosmo", + QuoteDenom: "ustrd", + Price: sdk.NewDec(5), + UpdatedAt: ctx.BlockTime(), + }, + } + return mockPrices, nil +} diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go new file mode 100644 index 0000000000..e04d984f4e --- /dev/null +++ b/x/icqoracle/keeper/msg_server.go @@ -0,0 +1,55 @@ +package keeper + +import ( + "context" + "time" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// AddTokenPrice adds a token to price tracking +func (ms msgServer) AddTokenPrice(goCtx context.Context, msg *types.MsgAddTokenPrice) (*types.MsgAddTokenPriceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO check admin + + tokenPrice := types.TokenPrice{ + BaseDenom: msg.BaseDenom, + QuoteDenom: msg.QuoteDenom, + UpdatedAt: time.Time{}, + Price: sdkmath.LegacyZeroDec(), + } + + err := ms.Keeper.SetTokenPrice(ctx, tokenPrice) + if err != nil { + return nil, err + } + + return &types.MsgAddTokenPriceResponse{}, nil +} + +// RemoveTokenPrice removes a token from price tracking +func (ms msgServer) RemoveTokenPrice(goCtx context.Context, msg *types.MsgRemoveTokenPrice) (*types.MsgRemoveTokenPriceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO check admin + + ms.Keeper.RemoveTokenPrice(ctx, msg.BaseDenom, msg.QuoteDenom) + + return &types.MsgRemoveTokenPriceResponse{}, nil +} diff --git a/x/icqoracle/keeper/params.go b/x/icqoracle/keeper/params.go new file mode 100644 index 0000000000..62d90a49bc --- /dev/null +++ b/x/icqoracle/keeper/params.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +// Writes params to the store +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + paramsBz := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsPrefix), paramsBz) +} + +// Retrieves the module parameters +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + paramsBz := store.Get([]byte(types.ParamsPrefix)) + if len(paramsBz) == 0 { + panic("module parameters not set") + } + k.cdc.MustUnmarshal(paramsBz, ¶ms) + return params +} diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go new file mode 100644 index 0000000000..bc6e5e75ec --- /dev/null +++ b/x/icqoracle/keeper/query.go @@ -0,0 +1,62 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +var _ types.QueryServer = Keeper{} + +// TokenPrice queries the current price for a specific token +func (k Keeper) TokenPrice(goCtx context.Context, req *types.QueryTokenPriceRequest) (*types.QueryTokenPriceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + price, err := k.GetTokenPrice(ctx, req.BaseDenom, req.QuoteDenom) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + return &types.QueryTokenPriceResponse{ + TokenPrice: price, + }, nil +} + +// TokenPrices queries all token prices +func (k Keeper) TokenPrices(goCtx context.Context, req *types.QueryTokenPricesRequest) (*types.QueryTokenPricesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + prices := k.GetAllTokenPrices(ctx) + + return &types.QueryTokenPricesResponse{ + TokenPrices: prices, + }, nil +} + +// Params queries the oracle parameters +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + params := k.GetParams(ctx) + + return &types.QueryParamsResponse{ + Params: params, + }, nil +} diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 0488916fb7..e077191be8 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -31,11 +31,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // TokenPrice stores latest price data for a token type TokenPrice struct { // Token denom (e.g. "uatom", "uosmo") - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + // Quote denom (e.g. ustrd, uusdc) + QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` // Price in USDC or STRD - Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` + Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` // Last update timestamp - UpdatedAt time.Time `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + UpdatedAt time.Time `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` } func (m *TokenPrice) Reset() { *m = TokenPrice{} } @@ -71,9 +73,16 @@ func (m *TokenPrice) XXX_DiscardUnknown() { var xxx_messageInfo_TokenPrice proto.InternalMessageInfo -func (m *TokenPrice) GetDenom() string { +func (m *TokenPrice) GetBaseDenom() string { if m != nil { - return m.Denom + return m.BaseDenom + } + return "" +} + +func (m *TokenPrice) GetQuoteDenom() string { + if m != nil { + return m.QuoteDenom } return "" } @@ -87,10 +96,14 @@ func (m *TokenPrice) GetUpdatedAt() time.Time { // OracleParams stores global oracle parameters type Params struct { + // Osmosis chain identifier + OsmosisChainId string `protobuf:"bytes,1,opt,name=osmosis_chain_id,json=osmosisChainId,proto3" json:"osmosis_chain_id" yaml:"osmosis_chain_id"` + // Osmosis IBC connection identifier + OsmosisConnectionId string `protobuf:"bytes,2,opt,name=osmosis_connection_id,json=osmosisConnectionId,proto3" json:"osmosis_connection_id" yaml:"osmosis_connection_id"` // Time between price updates - UpdateIntervalSec uint64 `protobuf:"varint,1,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` + UpdateIntervalSec uint64 `protobuf:"varint,3,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` // Max time before price is stale - TimeoutSec uint64 `protobuf:"varint,2,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec" yaml:"timeout_sec"` + TimeoutSec uint64 `protobuf:"varint,4,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec" yaml:"timeout_sec"` } func (m *Params) Reset() { *m = Params{} } @@ -126,6 +139,20 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetOsmosisChainId() string { + if m != nil { + return m.OsmosisChainId + } + return "" +} + +func (m *Params) GetOsmosisConnectionId() string { + if m != nil { + return m.OsmosisConnectionId + } + return "" +} + func (m *Params) GetUpdateIntervalSec() uint64 { if m != nil { return m.UpdateIntervalSec @@ -148,32 +175,38 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 387 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xb1, 0xae, 0xd3, 0x30, - 0x14, 0x86, 0xe3, 0x0b, 0xf7, 0x8a, 0xeb, 0x2e, 0x10, 0x3a, 0x54, 0x41, 0x8a, 0xab, 0x20, 0xa4, - 0x2e, 0xd8, 0x52, 0x0b, 0x03, 0x6c, 0x04, 0x84, 0x84, 0x54, 0xa4, 0x2a, 0xed, 0xc4, 0x52, 0x39, - 0x8e, 0x49, 0xa3, 0xc6, 0x75, 0x88, 0x9d, 0x8a, 0xbe, 0x45, 0x9f, 0x81, 0x97, 0xe0, 0x15, 0x3a, - 0x76, 0x44, 0x0c, 0x01, 0xb5, 0x5b, 0xc7, 0x3e, 0x01, 0x4a, 0x9c, 0xa2, 0x0c, 0xdd, 0x7c, 0xbe, - 0xff, 0x9c, 0x5f, 0xbf, 0xce, 0x31, 0xec, 0x2b, 0x9d, 0x27, 0x11, 0x27, 0x09, 0xfb, 0x26, 0x73, - 0xca, 0xd2, 0xd6, 0x0b, 0x67, 0xb9, 0xd4, 0xd2, 0x7e, 0x6c, 0x3a, 0xf0, 0x7f, 0xee, 0x74, 0x63, - 0x19, 0xcb, 0x5a, 0x24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 0xa9, 0xed, 0x5f, 0x9c, 0x4a, 0xd4, - 0xc6, 0xe7, 0x12, 0xd9, 0xc6, 0xb6, 0x05, 0xbd, 0x00, 0x36, 0xd5, 0x94, 0x33, 0xff, 0xf3, 0xee, - 0xe0, 0x82, 0xfd, 0xc1, 0x05, 0x7f, 0x0f, 0x2e, 0xd8, 0x1e, 0x5d, 0x6b, 0x7f, 0x74, 0xad, 0x5f, - 0x47, 0xd7, 0xfa, 0x32, 0x8a, 0x13, 0xbd, 0x28, 0x42, 0xcc, 0xa4, 0x20, 0xd3, 0xfa, 0x98, 0x2f, - 0xc7, 0x34, 0x54, 0xa4, 0x39, 0xfd, 0x7a, 0xf8, 0x8a, 0x7c, 0x6f, 0x7d, 0x00, 0xbd, 0xc9, 0xb8, - 0x0a, 0xef, 0xea, 0x8d, 0x8d, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x2c, 0x54, 0xd4, 0x21, - 0x02, 0x00, 0x00, + // 482 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x41, 0x6f, 0xd3, 0x30, + 0x18, 0x86, 0x1b, 0x56, 0x26, 0xea, 0x4a, 0x68, 0x64, 0x20, 0xaa, 0x02, 0x71, 0x15, 0x84, 0xb4, + 0x0b, 0xb1, 0xb4, 0xc1, 0x61, 0xdc, 0xc8, 0x26, 0xa4, 0x4a, 0x43, 0x9a, 0xd2, 0x5d, 0xe0, 0x12, + 0xb9, 0x8e, 0x49, 0xad, 0xd5, 0x71, 0x16, 0x3b, 0x13, 0x3d, 0xf2, 0x0f, 0xf6, 0xb3, 0x76, 0xe0, + 0xb0, 0x23, 0xe2, 0x60, 0x50, 0x7b, 0xeb, 0xb1, 0xbf, 0x00, 0xc5, 0x4e, 0xab, 0x68, 0xf4, 0x66, + 0x3f, 0xef, 0xeb, 0xf7, 0xfb, 0x6c, 0x7f, 0x60, 0x20,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0f, 0xdf, 0xa1, 0xef, 0x8d, 0xa1, 0x57, 0xb3, 0x9c, 0xca, 0xf1, + 0xae, 0xf9, 0xfb, 0xa3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xa9, 0xe9, 0x40, 0x15, 0x03, + 0x00, 0x00, } func (m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -203,7 +236,7 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintIcqoracle(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 { size := m.Price.Size() i -= size @@ -213,11 +246,18 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintIcqoracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.Denom))) + dAtA[i] = 0x1a + if len(m.QuoteDenom) > 0 { + i -= len(m.QuoteDenom) + copy(dAtA[i:], m.QuoteDenom) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.QuoteDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.BaseDenom))) i-- dAtA[i] = 0xa } @@ -247,12 +287,26 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.TimeoutSec != 0 { i = encodeVarintIcqoracle(dAtA, i, uint64(m.TimeoutSec)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x20 } if m.UpdateIntervalSec != 0 { i = encodeVarintIcqoracle(dAtA, i, uint64(m.UpdateIntervalSec)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x18 + } + if len(m.OsmosisConnectionId) > 0 { + i -= len(m.OsmosisConnectionId) + copy(dAtA[i:], m.OsmosisConnectionId) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisConnectionId))) + i-- + dAtA[i] = 0x12 + } + if len(m.OsmosisChainId) > 0 { + i -= len(m.OsmosisChainId) + copy(dAtA[i:], m.OsmosisChainId) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisChainId))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -274,7 +328,11 @@ func (m *TokenPrice) Size() (n int) { } var l int _ = l - l = len(m.Denom) + l = len(m.BaseDenom) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } + l = len(m.QuoteDenom) if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) } @@ -291,6 +349,14 @@ func (m *Params) Size() (n int) { } var l int _ = l + l = len(m.OsmosisChainId) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } + l = len(m.OsmosisConnectionId) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } if m.UpdateIntervalSec != 0 { n += 1 + sovIcqoracle(uint64(m.UpdateIntervalSec)) } @@ -337,7 +403,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -365,9 +431,41 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.BaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QuoteDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) } @@ -401,7 +499,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) } @@ -485,6 +583,70 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisConnectionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisConnectionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UpdateIntervalSec", wireType) } @@ -503,7 +665,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 2: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutSec", wireType) } diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 5936350673..311b4ce67d 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -5,4 +5,11 @@ const ( // StoreKey defines the primary module store key StoreKey = ModuleName + + // RouterKey defines the routing key + RouterKey = ModuleName + + ParamsPrefix = "params" + KeyPricePrefix = "price" + KeyLastUpdateTime = "last_update_time" ) diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go new file mode 100644 index 0000000000..5375463b74 --- /dev/null +++ b/x/icqoracle/types/msgs.go @@ -0,0 +1,118 @@ +package types + +import ( + "errors" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" +) + +const ( + TypeMsgAddTokenPrice = "add_token_price" + TypeMsgRemoveTokenPrice = "remove_token_price" +) + +var ( + _ sdk.Msg = &MsgAddTokenPrice{} + _ sdk.Msg = &MsgRemoveTokenPrice{} + + // Implement legacy interface for ledger support + _ legacytx.LegacyMsg = &MsgAddTokenPrice{} + _ legacytx.LegacyMsg = &MsgRemoveTokenPrice{} +) + +// ---------------------------------------------- +// MsgClaim +// ---------------------------------------------- + +func NewMsgAddTokenPrice(sender, baseDenom, quoteDenom string) *MsgAddTokenPrice { + return &MsgAddTokenPrice{ + Sender: sender, + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } +} + +func (msg MsgAddTokenPrice) Type() string { + return TypeMsgAddTokenPrice +} + +func (msg MsgAddTokenPrice) Route() string { + return RouterKey +} + +func (msg *MsgAddTokenPrice) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgAddTokenPrice) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgAddTokenPrice) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } + if msg.BaseDenom == "" { + return errors.New("base-denom must be specified") + } + if msg.QuoteDenom == "" { + return errors.New("quote-denom must be specified") + } + + return nil +} + +// ---------------------------------------------- +// MsgRemoveTokenPrice +// ---------------------------------------------- + +func NewMsgRemoveTokenPrice(sender, baseDenom, quoteDenom string) *MsgRemoveTokenPrice { + return &MsgRemoveTokenPrice{ + Sender: sender, + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } +} + +func (msg MsgRemoveTokenPrice) Type() string { + return TypeMsgRemoveTokenPrice +} + +func (msg MsgRemoveTokenPrice) Route() string { + return RouterKey +} + +func (msg *MsgRemoveTokenPrice) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgRemoveTokenPrice) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRemoveTokenPrice) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } + if msg.BaseDenom == "" { + return errors.New("base-denom must be specified") + } + if msg.QuoteDenom == "" { + return errors.New("quote-denom must be specified") + } + + return nil +} diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 1685e834d4..61610cdf16 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -33,7 +33,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryTokenPriceRequest is the request type for the Query/TokenPrice RPC // method type QueryTokenPriceRequest struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` } func (m *QueryTokenPriceRequest) Reset() { *m = QueryTokenPriceRequest{} } @@ -69,9 +70,16 @@ func (m *QueryTokenPriceRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTokenPriceRequest proto.InternalMessageInfo -func (m *QueryTokenPriceRequest) GetDenom() string { +func (m *QueryTokenPriceRequest) GetBaseDenom() string { if m != nil { - return m.Denom + return m.BaseDenom + } + return "" +} + +func (m *QueryTokenPriceRequest) GetQuoteDenom() string { + if m != nil { + return m.QuoteDenom } return "" } @@ -316,39 +324,41 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 501 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x8a, 0xd3, 0x40, - 0x18, 0xc7, 0x3b, 0xbb, 0x6e, 0xc1, 0xaf, 0x1e, 0x64, 0x2c, 0x5a, 0x42, 0x89, 0x25, 0xa8, 0xdb, - 0x5d, 0x70, 0x86, 0xed, 0x8a, 0x0f, 0xa0, 0xa8, 0x17, 0x17, 0x6a, 0xf5, 0xe4, 0x41, 0x99, 0x64, - 0x87, 0x18, 0xd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x6d, 0xe6, 0x88, - 0x6f, 0xfc, 0xc7, 0xbf, 0xf2, 0x5c, 0xce, 0xcd, 0x06, 0xd5, 0x39, 0x00, 0xcc, 0xf3, 0x1d, 0x9c, - 0x2e, 0x5c, 0x74, 0xb6, 0x70, 0xd1, 0xaf, 0x85, 0x8b, 0x3e, 0x2d, 0xdd, 0xd6, 0xd9, 0xd2, 0x6d, - 0xfd, 0x58, 0xba, 0xad, 0xe7, 0xfb, 0x61, 0xa4, 0x5e, 0xcd, 0x7d, 0x12, 0x88, 0x29, 0x7d, 0xaa, - 0x5d, 0x6e, 0x3f, 0x66, 0xbe, 0xcc, 0x1d, 0x8f, 0x47, 0x77, 0xe8, 0x9b, 0x92, 0xaf, 0x3a, 0x49, - 0xb8, 0xf4, 0xdb, 0xfa, 0xbf, 0x60, 0xff, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x87, 0x3f, 0xe0, - 0xb9, 0xbf, 0x04, 0x00, 0x00, + // 532 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xc7, 0xb3, 0xa9, 0x06, 0xfa, 0xc4, 0x83, 0x8c, 0x45, 0xc3, 0x12, 0xb7, 0x61, 0xf1, 0x25, + 0x16, 0x9c, 0xa1, 0xa9, 0x78, 0x10, 0x4f, 0xf5, 0xed, 0x62, 0x21, 0x46, 0x0f, 0xe2, 0xc1, 0x32, + 0xbb, 0x1d, 0xd6, 0xc5, 0x66, 0x67, 0xb3, 0x33, 0x29, 0x96, 0x52, 0x04, 0x3f, 0x80, 0x08, 0x7e, + 0x06, 0x2f, 0x7e, 0x0b, 0x6f, 0x3d, 0x16, 0xbc, 0x78, 0x12, 0x49, 0xfc, 0x20, 0x32, 0x2f, 0x9b, + 0xdd, 0xb8, 0x4a, 0xd2, 0xdb, 0xf0, 0x7f, 0xfe, 0xcf, 0x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d, 0xa0, 0x7b, 0x7d, 0x81, 0xeb, 0x0c, 0x00, 0xe6, 0x46, 0x77, 0x4e, 0x26, + 0x9e, 0x73, 0x3a, 0xf1, 0x9c, 0x5f, 0x13, 0xcf, 0xf9, 0x34, 0xf5, 0x6a, 0xa7, 0x53, 0xaf, 0xf6, + 0x63, 0xea, 0xd5, 0x5e, 0x6d, 0x45, 0xb1, 0x7c, 0x33, 0x0e, 0x70, 0xc8, 0x87, 0xe4, 0xb9, 0x4e, + 0xb9, 0xfd, 0x94, 0x06, 0x22, 0x4f, 0x3c, 0xe8, 0xdd, 0x21, 0xef, 0x4a, 0xb9, 0xf2, 0x30, 0x65, + 0x22, 0x68, 0xe8, 0x3f, 0x92, 0xad, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xe3, 0x6b, 0x20, + 0xfc, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -529,10 +539,17 @@ func (m *QueryTokenPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + if len(m.QuoteDenom) > 0 { + i -= len(m.QuoteDenom) + copy(dAtA[i:], m.QuoteDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseDenom))) i-- dAtA[i] = 0xa } @@ -729,7 +746,11 @@ func (m *QueryTokenPriceRequest) Size() (n int) { } var l int _ = l - l = len(m.Denom) + l = len(m.BaseDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteDenom) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -836,7 +857,39 @@ func (m *QueryTokenPriceRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", 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.BaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -864,7 +917,7 @@ func (m *QueryTokenPriceRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/icqoracle/types/query.pb.gw.go b/x/icqoracle/types/query.pb.gw.go index 091e66b3c8..6ca0bf2850 100644 --- a/x/icqoracle/types/query.pb.gw.go +++ b/x/icqoracle/types/query.pb.gw.go @@ -44,15 +44,26 @@ func request_Query_TokenPrice_0(ctx context.Context, marshaler runtime.Marshaler _ = err ) - val, ok = pathParams["denom"] + val, ok = pathParams["quote_denom"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "quote_denom") } - protoReq.Denom, err = runtime.String(val) + protoReq.QuoteDenom, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "quote_denom", err) + } + + val, ok = pathParams["base_denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "base_denom") + } + + protoReq.BaseDenom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "base_denom", err) } msg, err := client.TokenPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -71,15 +82,26 @@ func local_request_Query_TokenPrice_0(ctx context.Context, marshaler runtime.Mar _ = err ) - val, ok = pathParams["denom"] + val, ok = pathParams["quote_denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "quote_denom") + } + + protoReq.QuoteDenom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "quote_denom", err) + } + + val, ok = pathParams["base_denom"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "base_denom") } - protoReq.Denom, err = runtime.String(val) + protoReq.BaseDenom, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "base_denom", err) } msg, err := server.TokenPrice(ctx, &protoReq) @@ -321,7 +343,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"stride", "icqoracle", "v1beta1", "price", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"stride", "icqoracle", "v1beta1", "price", "quote_denom", "base_denom"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index e076bc86d8..f7ca6ae31c 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -30,116 +30,20 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgUpdateParams defines the message for updating module parameters -type MsgUpdateParams struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // How often to fetch the price - UpdateIntervalSec uint64 `protobuf:"varint,2,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec,omitempty"` - // When price is considered stale - TimeoutSec uint64 `protobuf:"varint,3,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec,omitempty"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_be640eb75c1babd5, []int{0} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *MsgUpdateParams) GetUpdateIntervalSec() uint64 { - if m != nil { - return m.UpdateIntervalSec - } - return 0 -} - -func (m *MsgUpdateParams) GetTimeoutSec() uint64 { - if m != nil { - return m.TimeoutSec - } - return 0 -} - -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_be640eb75c1babd5, []int{1} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - // MsgAddTokenPrice defines the message for adding a new token to track prices type MsgAddTokenPrice struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Token denom (e.g. "uatom", "uosmo") + BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + // Quote denom (e.g. ustrd, uusdc) + QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` } func (m *MsgAddTokenPrice) Reset() { *m = MsgAddTokenPrice{} } func (m *MsgAddTokenPrice) String() string { return proto.CompactTextString(m) } func (*MsgAddTokenPrice) ProtoMessage() {} func (*MsgAddTokenPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_be640eb75c1babd5, []int{2} + return fileDescriptor_be640eb75c1babd5, []int{0} } func (m *MsgAddTokenPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -175,9 +79,16 @@ func (m *MsgAddTokenPrice) GetSender() string { return "" } -func (m *MsgAddTokenPrice) GetDenom() string { +func (m *MsgAddTokenPrice) GetBaseDenom() string { + if m != nil { + return m.BaseDenom + } + return "" +} + +func (m *MsgAddTokenPrice) GetQuoteDenom() string { if m != nil { - return m.Denom + return m.QuoteDenom } return "" } @@ -189,7 +100,7 @@ func (m *MsgAddTokenPriceResponse) Reset() { *m = MsgAddTokenPriceRespon func (m *MsgAddTokenPriceResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddTokenPriceResponse) ProtoMessage() {} func (*MsgAddTokenPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_be640eb75c1babd5, []int{3} + return fileDescriptor_be640eb75c1babd5, []int{1} } func (m *MsgAddTokenPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -222,14 +133,17 @@ var xxx_messageInfo_MsgAddTokenPriceResponse proto.InternalMessageInfo // tracking type MsgRemoveTokenPrice struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Token denom (e.g. "uatom", "uosmo") + BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + // Quote denom (e.g. ustrd, uusdc) + QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` } func (m *MsgRemoveTokenPrice) Reset() { *m = MsgRemoveTokenPrice{} } func (m *MsgRemoveTokenPrice) String() string { return proto.CompactTextString(m) } func (*MsgRemoveTokenPrice) ProtoMessage() {} func (*MsgRemoveTokenPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_be640eb75c1babd5, []int{4} + return fileDescriptor_be640eb75c1babd5, []int{2} } func (m *MsgRemoveTokenPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -265,9 +179,16 @@ func (m *MsgRemoveTokenPrice) GetSender() string { return "" } -func (m *MsgRemoveTokenPrice) GetDenom() string { +func (m *MsgRemoveTokenPrice) GetBaseDenom() string { if m != nil { - return m.Denom + return m.BaseDenom + } + return "" +} + +func (m *MsgRemoveTokenPrice) GetQuoteDenom() string { + if m != nil { + return m.QuoteDenom } return "" } @@ -279,7 +200,7 @@ func (m *MsgRemoveTokenPriceResponse) Reset() { *m = MsgRemoveTokenPrice func (m *MsgRemoveTokenPriceResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveTokenPriceResponse) ProtoMessage() {} func (*MsgRemoveTokenPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_be640eb75c1babd5, []int{5} + return fileDescriptor_be640eb75c1babd5, []int{3} } func (m *MsgRemoveTokenPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -309,8 +230,6 @@ func (m *MsgRemoveTokenPriceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveTokenPriceResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgUpdateParams)(nil), "stride.icqoracle.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "stride.icqoracle.MsgUpdateParamsResponse") proto.RegisterType((*MsgAddTokenPrice)(nil), "stride.icqoracle.MsgAddTokenPrice") proto.RegisterType((*MsgAddTokenPriceResponse)(nil), "stride.icqoracle.MsgAddTokenPriceResponse") proto.RegisterType((*MsgRemoveTokenPrice)(nil), "stride.icqoracle.MsgRemoveTokenPrice") @@ -320,38 +239,32 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 488 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x41, 0x8b, 0xd3, 0x50, - 0x10, 0xc7, 0xfb, 0x76, 0xdd, 0x85, 0x8e, 0x8a, 0xdd, 0xec, 0xc2, 0xb6, 0x11, 0xe3, 0x1a, 0x51, - 0xd6, 0x42, 0x13, 0xdd, 0xaa, 0x87, 0xbd, 0xed, 0xde, 0x04, 0x03, 0x4b, 0xaa, 0x17, 0x11, 0x4a, - 0x9a, 0x0c, 0xe9, 0xc3, 0x4d, 0x5e, 0x7d, 0xf3, 0x5a, 0x76, 0x6f, 0xe2, 0xd1, 0x8b, 0x5e, 0xfc, - 0x1e, 0x3d, 0xe8, 0x77, 0x10, 0xbc, 0x2c, 0x9e, 0x3c, 0x4a, 0x7b, 0xe8, 0xd7, 0x90, 0x26, 0x69, - 0x31, 0x31, 0x50, 0x11, 0xf6, 0xd2, 0x32, 0x33, 0xbf, 0x79, 0xff, 0xff, 0x9b, 0x79, 0x81, 0x06, - 0x29, 0xc9, 0x03, 0xb4, 0xb9, 0xff, 0x56, 0x48, 0xcf, 0x3f, 0x45, 0x5b, 0x9d, 0x59, 0x03, 0x29, - 0x94, 0xd0, 0x6a, 0x69, 0xc9, 0x5a, 0x96, 0xf4, 0x5d, 0x5f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x51, 0x04, 0x00, 0x00, + // 395 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x2e, 0x29, 0xca, + 0x4c, 0x49, 0xd5, 0xcf, 0x4c, 0x2e, 0xcc, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0xa9, 0xd0, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x48, 0xe9, 0xc1, 0xa5, 0xa4, 0xc4, 0x93, 0xf3, + 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0xa9, 0x94, + 0x60, 0x62, 0x6e, 0x66, 0x5e, 0xbe, 0x3e, 0x98, 0x84, 0x0a, 0x49, 0x42, 0xd4, 0xc6, 0x83, 0x79, + 0xfa, 0x10, 0x0e, 0x44, 0x4a, 0x69, 0x27, 0x23, 0x97, 0x80, 0x6f, 0x71, 0xba, 0x63, 0x4a, 0x4a, + 0x48, 0x7e, 0x76, 0x6a, 0x5e, 0x40, 0x51, 0x66, 0x72, 0xaa, 0x90, 0x01, 0x17, 0x5b, 0x71, 0x6a, + 0x5e, 0x4a, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, + 0x50, 0x6d, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0xc1, 0x25, 0x45, 0x99, 0x79, 0xe9, 0x41, + 0x50, 0x75, 0x42, 0xb2, 0x5c, 0x5c, 0x49, 0x89, 0xc5, 0xa9, 0xf1, 0x29, 0xa9, 0x79, 0xf9, 0xb9, + 0x12, 0x4c, 0x20, 0x5d, 0x41, 0x9c, 0x20, 0x11, 0x17, 0x90, 0x80, 0x90, 0x3c, 0x17, 0x77, 0x61, + 0x69, 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xeb, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0x43, 0xb4, 0xcc, 0xc8, + 0x04, 0x25, 0x54, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x09, 0xdd, 0x18, 0x10, 0x00, + 0x00, 0xff, 0xff, 0x9f, 0xce, 0x8b, 0x45, 0x5e, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -366,8 +279,6 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // UpdateParams allows the admin to update the module parameters - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) // AddTokenPrice adds a new token to track prices for AddTokenPrice(ctx context.Context, in *MsgAddTokenPrice, opts ...grpc.CallOption) (*MsgAddTokenPriceResponse, error) // RemoveTokenPrice removes a token from price tracking @@ -382,15 +293,6 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) AddTokenPrice(ctx context.Context, in *MsgAddTokenPrice, opts ...grpc.CallOption) (*MsgAddTokenPriceResponse, error) { out := new(MsgAddTokenPriceResponse) err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/AddTokenPrice", in, out, opts...) @@ -411,8 +313,6 @@ func (c *msgClient) RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPric // MsgServer is the server API for Msg service. type MsgServer interface { - // UpdateParams allows the admin to update the module parameters - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) // AddTokenPrice adds a new token to track prices for AddTokenPrice(context.Context, *MsgAddTokenPrice) (*MsgAddTokenPriceResponse, error) // RemoveTokenPrice removes a token from price tracking @@ -423,9 +323,6 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} func (*UnimplementedMsgServer) AddTokenPrice(ctx context.Context, req *MsgAddTokenPrice) (*MsgAddTokenPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddTokenPrice not implemented") } @@ -437,24 +334,6 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/stride.icqoracle.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_AddTokenPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgAddTokenPrice) if err := dec(in); err != nil { @@ -495,10 +374,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "stride.icqoracle.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, { MethodName: "AddTokenPrice", Handler: _Msg_AddTokenPrice_Handler, @@ -512,69 +387,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "stride/icqoracle/tx.proto", } -func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TimeoutSec != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.TimeoutSec)) - i-- - dAtA[i] = 0x18 - } - if m.UpdateIntervalSec != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.UpdateIntervalSec)) - i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgAddTokenPrice) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -595,10 +407,17 @@ func (m *MsgAddTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + if len(m.QuoteDenom) > 0 { + i -= len(m.QuoteDenom) + copy(dAtA[i:], m.QuoteDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.QuoteDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.BaseDenom))) i-- dAtA[i] = 0x12 } @@ -655,10 +474,17 @@ func (m *MsgRemoveTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + if len(m.QuoteDenom) > 0 { + i -= len(m.QuoteDenom) + copy(dAtA[i:], m.QuoteDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.QuoteDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.BaseDenom))) i-- dAtA[i] = 0x12 } @@ -706,7 +532,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgUpdateParams) Size() (n int) { +func (m *MsgAddTokenPrice) Size() (n int) { if m == nil { return 0 } @@ -716,35 +542,11 @@ func (m *MsgUpdateParams) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.UpdateIntervalSec != 0 { - n += 1 + sovTx(uint64(m.UpdateIntervalSec)) - } - if m.TimeoutSec != 0 { - n += 1 + sovTx(uint64(m.TimeoutSec)) - } - return n -} - -func (m *MsgUpdateParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgAddTokenPrice) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) + l = len(m.BaseDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Denom) + l = len(m.QuoteDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -770,7 +572,11 @@ func (m *MsgRemoveTokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Denom) + l = len(m.BaseDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.QuoteDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -792,7 +598,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { +func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -815,10 +621,10 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddTokenPrice: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -854,146 +660,8 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateIntervalSec", wireType) - } - m.UpdateIntervalSec = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UpdateIntervalSec |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeoutSec", wireType) - } - m.TimeoutSec = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TimeoutSec |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx - } - 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: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgAddTokenPrice) 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 ErrIntOverflowTx - } - 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: MsgAddTokenPrice: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1021,11 +689,11 @@ func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.BaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1053,7 +721,7 @@ func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1189,7 +857,39 @@ func (m *MsgRemoveTokenPrice) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1217,7 +917,7 @@ func (m *MsgRemoveTokenPrice) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From b784b294557b8bdddb69d1094ff12cce10c19e0e Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 11 Dec 2024 13:11:02 +0200 Subject: [PATCH 005/115] osmosis SpotPriceV2 icq boilerplate --- proto/stride/icqoracle/icqoracle.proto | 3 + x/icqoracle/keeper/abci.go | 23 ++++ x/icqoracle/keeper/icq.go | 145 +++++++++++++++++++++++++ x/icqoracle/keeper/icqcallbacks.go | 44 ++++++++ x/icqoracle/keeper/keeper.go | 33 ++++-- x/icqoracle/keeper/msg_server.go | 9 +- x/icqoracle/types/icqoracle.pb.go | 107 ++++++++++++------ x/interchainquery/keeper/queries.go | 4 + 8 files changed, 324 insertions(+), 44 deletions(-) create mode 100644 x/icqoracle/keeper/icq.go create mode 100644 x/icqoracle/keeper/icqcallbacks.go diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index 34d7f03406..48dc2aad36 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -23,6 +23,9 @@ message TokenPrice { // Last update timestamp google.protobuf.Timestamp updated_at = 4 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + + // Whether there is a price query currently in progress + bool query_in_progress = 5; } // OracleParams stores global oracle parameters diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index daa56e7914..792ff46fa3 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -1,8 +1,31 @@ package keeper import ( + "time" + sdk "github.com/cosmos/cosmos-sdk/types" ) func (k Keeper) BeginBlocker(ctx sdk.Context) { + // Get all token prices + params := k.GetParams(ctx) + + currentTime := ctx.BlockTime() + + // Iterate through each token price + tokenPrices := k.GetAllTokenPrices(ctx) + for _, tokenPrice := range tokenPrices { + // Get last update time for this token + lastUpdate := tokenPrice.UpdatedAt + + // If never updated or update interval has passed + if lastUpdate.IsZero() || !tokenPrice.QueryInProgress && currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) { + // Update price for this specific token + err := k.SubmitSpotPriceV2CallbackICQ(ctx, tokenPrice) + if err != nil { + // TODO handle error, maybe log it + continue + } + } + } } diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go new file mode 100644 index 0000000000..550b504281 --- /dev/null +++ b/x/icqoracle/keeper/icq.go @@ -0,0 +1,145 @@ +package keeper + +import ( + "fmt" + "regexp" + "time" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/utils" + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + icqkeeper "github.com/Stride-Labs/stride/v24/x/interchainquery/keeper" + icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" +) + +// Submits an ICQ to get a validator's shares to tokens rate +func (k Keeper) SubmitSpotPriceV2CallbackICQ( + ctx sdk.Context, + tokenPrice types.TokenPrice, +) error { + k.Logger(ctx).Info(utils.LogWithPriceToken(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, "Submitting SpotPriceV2 ICQ")) + + params := k.GetParams(ctx) + + // Submit validator sharesToTokens rate ICQ + // Considering this query is executed manually, we can be conservative with the timeout + query := icqtypes.Query{ + Id: fmt.Sprintf("%s|%s-%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, ctx.BlockHeight()), // TODO fix? + ChainId: params.OsmosisChainId, + ConnectionId: params.OsmosisConnectionId, + QueryType: icqtypes.STAKING_STORE_QUERY_WITH_PROOF, // TODO fix + RequestData: []byte{}, // TODO fix + CallbackModule: types.ModuleName, + CallbackId: "banana", // TODO fix + CallbackData: []byte{}, // TODO fix + TimeoutDuration: 10 * time.Minute, // TODO fix + TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, // TODO fix + } + if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, "Error submitting SpotPriceV2 ICQ, error '%s'", err.Error())) + return err + } + + if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, true); err != nil { + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, "Error updating queryInProgress=true, error '%s'", err.Error())) + return err + } + + return nil +} + +var queryIdRegex = regexp.MustCompile(`^(.+)\|(.+)-(\d+)$`) + +// Helper function to parse the ID string +func ParseQueryID(id string) (baseDenom, quoteDenom, blockHeight string, ok bool) { + matches := queryIdRegex.FindStringSubmatch(id) + if len(matches) != 4 { + return "", "", "", false + } + return matches[1], matches[2], matches[3], true +} + +func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { + baseDenom, quoteDenom, _, ok := ParseQueryID(query.Id) + if !ok { + return fmt.Errorf("unable to parse baseDenom and quoteDenom from queryId '%s'", query.Id) + } + + k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(baseDenom, quoteDenom, "SpotPriceV2", + "Starting SpotPriceV2 ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) + + // Unmarshal the query response args to determine the balance + spotPrice, err := icqkeeper.UnmarshalSpotPriceFromSpotPriceV2Query(k.cdc, args) + if err != nil { + return errorsmod.Wrap(err, "unable to determine spot price from query response") + } + + tokenPrice := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + Price: spotPrice, + UpdatedAt: ctx.BlockTime(), + QueryInProgress: false, + } + + if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { + return errorsmod.Wrap(err, "unable to update spot price from query response") + } + + return nil + + // k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_FeeBalance, + // "Query response - Fee Balance: %v %s", feeBalanceAmount, hostZone.HostDenom)) + + // // Confirm the balance is greater than zero + // if feeBalanceAmount.LTE(sdkmath.ZeroInt()) { + // k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_FeeBalance, + // "No balance to transfer for address: %s, balance: %v", hostZone.FeeIcaAddress, feeBalanceAmount)) + // return nil + // } + + // // Confirm the fee account has been initiated + // if hostZone.FeeIcaAddress == "" { + // return errorsmod.Wrapf(types.ErrICAAccountNotFound, "no fee account found for %s", chainId) + // } + + // // The ICA and transfer should both timeout before the end of the epoch + // timeout, err := k.GetICATimeoutNanos(ctx, epochtypes.STRIDE_EPOCH) + // if err != nil { + // return errorsmod.Wrapf(err, "Failed to get ICATimeout from %s epoch", epochtypes.STRIDE_EPOCH) + // } + + // // get counterparty chain's transfer channel + // transferChannel, found := k.IBCKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) + // if !found { + // return errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "transfer channel %s not found", hostZone.TransferChannelId) + // } + // counterpartyChannelId := transferChannel.Counterparty.ChannelId + + // // Prepare a MsgTransfer from the fee account to the rewards collector account + // rewardsCoin := sdk.NewCoin(hostZone.HostDenom, feeBalanceAmount) + // rewardsCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() + // transferMsg := ibctypes.NewMsgTransfer( + // transfertypes.PortID, + // counterpartyChannelId, + // rewardsCoin, + // hostZone.FeeIcaAddress, + // rewardsCollectorAddress.String(), + // clienttypes.Height{}, + // timeout, + // "", + // ) + + // msgs := []proto.Message{transferMsg} + // k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_FeeBalance, + // "Preparing MsgTransfer of %v from the fee account to the rewards collector module account (for commission)", rewardsCoin.String())) + + // // Send the transaction through SubmitTx + // if _, err := k.SubmitTxsStrideEpoch(ctx, hostZone.ConnectionId, msgs, types.ICAAccountType_FEE, ICACallbackID_Reinvest, nil); err != nil { + // return errorsmod.Wrapf(types.ErrICATxFailed, "Failed to SubmitTxs, Messages: %v, err: %s", msgs, err.Error()) + // } + + // return nil +} diff --git a/x/icqoracle/keeper/icqcallbacks.go b/x/icqoracle/keeper/icqcallbacks.go new file mode 100644 index 0000000000..251b4b39f2 --- /dev/null +++ b/x/icqoracle/keeper/icqcallbacks.go @@ -0,0 +1,44 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" +) + +const ( + ICQCallbackID_SpotPriceV2 = "spotpricev2" +) + +// ICQCallbacks wrapper struct for stakeibc keeper +type ICQCallback func(Keeper, sdk.Context, []byte, icqtypes.Query) error + +type ICQCallbacks struct { + k Keeper + callbacks map[string]ICQCallback +} + +var _ icqtypes.QueryCallbacks = ICQCallbacks{} + +func (k Keeper) ICQCallbackHandler() ICQCallbacks { + return ICQCallbacks{k, make(map[string]ICQCallback)} +} + +func (c ICQCallbacks) CallICQCallback(ctx sdk.Context, id string, args []byte, query icqtypes.Query) error { + return c.callbacks[id](c.k, ctx, args, query) +} + +func (c ICQCallbacks) HasICQCallback(id string) bool { + _, found := c.callbacks[id] + return found +} + +func (c ICQCallbacks) AddICQCallback(id string, fn interface{}) icqtypes.QueryCallbacks { + c.callbacks[id] = fn.(ICQCallback) + return c +} + +func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks { + return c. + AddICQCallback(ICQCallbackID_SpotPriceV2, ICQCallback(SpotPriceV2Callback)) +} diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 6295a426e5..2b7527617e 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -100,6 +100,21 @@ func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom s store.Delete(key) } +func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, queryInProgress bool) error { + tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom) + if err != nil { + return err + } + + tokenPrice.QueryInProgress = queryInProgress + err = k.SetTokenPrice(ctx, tokenPrice) + if err != nil { + return err + } + + return nil +} + // GetTokenPrice retrieves price data for a token func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string) (types.TokenPrice, error) { store := ctx.KVStore(k.storeKey) @@ -140,16 +155,18 @@ func (k Keeper) QueryOsmosisPrices(ctx sdk.Context) ([]types.TokenPrice, error) // This is a placeholder that returns mock data mockPrices := []types.TokenPrice{ { - BaseDenom: "uatom", - QuoteDenom: "ustrd", - Price: sdk.NewDec(10), - UpdatedAt: ctx.BlockTime(), + BaseDenom: "uatom", + QuoteDenom: "ustrd", + Price: sdk.NewDec(10), + UpdatedAt: ctx.BlockTime(), + QueryInProgress: false, }, { - BaseDenom: "uosmo", - QuoteDenom: "ustrd", - Price: sdk.NewDec(5), - UpdatedAt: ctx.BlockTime(), + BaseDenom: "uosmo", + QuoteDenom: "ustrd", + Price: sdk.NewDec(5), + UpdatedAt: ctx.BlockTime(), + QueryInProgress: false, }, } return mockPrices, nil diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index e04d984f4e..2b4a64338f 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -29,10 +29,11 @@ func (ms msgServer) AddTokenPrice(goCtx context.Context, msg *types.MsgAddTokenP // TODO check admin tokenPrice := types.TokenPrice{ - BaseDenom: msg.BaseDenom, - QuoteDenom: msg.QuoteDenom, - UpdatedAt: time.Time{}, - Price: sdkmath.LegacyZeroDec(), + BaseDenom: msg.BaseDenom, + QuoteDenom: msg.QuoteDenom, + UpdatedAt: time.Time{}, + Price: sdkmath.LegacyZeroDec(), + QueryInProgress: false, } err := ms.Keeper.SetTokenPrice(ctx, tokenPrice) diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index e077191be8..7a67819807 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -38,6 +38,8 @@ type TokenPrice struct { Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` // Last update timestamp UpdatedAt time.Time `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + // Whether there is a price query currently in progress + QueryInProgress bool `protobuf:"varint,5,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` } func (m *TokenPrice) Reset() { *m = TokenPrice{} } @@ -94,6 +96,13 @@ func (m *TokenPrice) GetUpdatedAt() time.Time { return time.Time{} } +func (m *TokenPrice) GetQueryInProgress() bool { + if m != nil { + return m.QueryInProgress + } + return false +} + // OracleParams stores global oracle parameters type Params struct { // Osmosis chain identifier @@ -175,38 +184,39 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x41, 0x6f, 0xd3, 0x30, - 0x18, 0x86, 0x1b, 0x56, 0x26, 0xea, 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 0xca, 0xc4, 0xb7, 0x4d, 0xfc, 0x9b, 0xa5, 0x86, 0x4d, 0xbc, 0xd2, 0xd0, - 0xb5, 0xb1, 0x0d, 0xe8, 0x47, 0xa0, 0xde, 0x8d, 0x28, 0x09, 0x3f, 0xdf, 0xce, 0x3d, 0xe7, 0x6e, - 0xee, 0x39, 0x7f, 0xe7, 0x9e, 0x73, 0xb3, 0xf0, 0x5a, 0x77, 0x0b, 0xaf, 0xf5, 0x6b, 0xe1, 0xb5, - 0xbe, 0x1e, 0xa5, 0x4c, 0x4d, 0xca, 0x71, 0x40, 0x04, 0x47, 0x23, 0x33, 0xc0, 0x6f, 0xcf, 0xf0, - 0x58, 0xa2, 0x7a, 0xdc, 0xaf, 0x0f, 0xdf, 0xa1, 0xef, 0x8d, 0xa1, 0x57, 0xb3, 0x9c, 0xca, 0xf1, - 0xae, 0xf9, 0xfb, 0xa3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xa9, 0xe9, 0x40, 0x15, 0x03, - 0x00, 0x00, + // 512 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xc1, 0x6f, 0xd3, 0x30, + 0x14, 0xc6, 0x1b, 0xd6, 0x4d, 0xab, 0x2b, 0xc1, 0xe6, 0x81, 0xa8, 0x0a, 0xc4, 0x55, 0x10, 0x52, + 0x85, 0x44, 0x22, 0x6d, 0x70, 0x18, 0x37, 0xb2, 0x09, 0xa9, 0xd2, 0x90, 0xaa, 0x74, 0x17, 0xb8, + 0x44, 0xae, 0x63, 0x52, 0x6b, 0x4d, 0x9c, 0xc6, 0xce, 0x44, 0x8f, 0xfc, 0x07, 0xfb, 0xb3, 0x76, + 0xdc, 0x11, 0x71, 0x30, 0xa8, 0xbd, 0xf5, 0xd8, 0x13, 0x47, 0x14, 0x3b, 0xad, 0xaa, 0xad, 0x37, + 0xfb, 0xf7, 0x7d, 0x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b6, 0x75, 0x33, 0xb7, 0x6b, 0x77, 0x73, 0xbb, 0xf6, 0x6b, 0x6e, 0xd7, 0xbe, 0x9d, 0xc4, + 0x4c, 0x8e, 0x8a, 0xa1, 0x4b, 0x78, 0xe2, 0x0d, 0xf4, 0xb0, 0xbf, 0xbb, 0xc0, 0x43, 0xe1, 0x55, + 0x4f, 0xe3, 0xfa, 0xf8, 0xbd, 0xf7, 0x63, 0xe3, 0x81, 0xc8, 0x69, 0x46, 0xc5, 0x70, 0x4f, 0xcf, + 0xc9, 0xc9, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x78, 0xcc, 0x04, 0x81, 0x41, 0x03, 0x00, 0x00, } func (m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -229,6 +239,16 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.QueryInProgress { + i-- + if m.QueryInProgress { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) if err1 != nil { return 0, err1 @@ -340,6 +360,9 @@ func (m *TokenPrice) Size() (n int) { n += 1 + l + sovIcqoracle(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) n += 1 + l + sovIcqoracle(uint64(l)) + if m.QueryInProgress { + n += 2 + } return n } @@ -532,6 +555,26 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.QueryInProgress = bool(v != 0) default: iNdEx = preIndex skippy, err := skipIcqoracle(dAtA[iNdEx:]) diff --git a/x/interchainquery/keeper/queries.go b/x/interchainquery/keeper/queries.go index 7a49d14757..47dfffc5bb 100644 --- a/x/interchainquery/keeper/queries.go +++ b/x/interchainquery/keeper/queries.go @@ -178,3 +178,7 @@ func UnmarshalAmountFromBalanceQuery(cdc codec.BinaryCodec, queryResponseBz []by return sdkmath.Int{}, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unable to unmarshal balance query response %v as sdkmath.Int (err: %s) or sdk.Coin (err: %s)", queryResponseBz, intError.Error(), coinError.Error()) } + +func UnmarshalSpotPriceFromSpotPriceV2Query(cdc codec.BinaryCodec, queryResponseBz []byte) (price sdkmath.LegacyDec, err error) { + return sdkmath.LegacyDec{}, nil +} From 75b8d79093fb9a4e202c5256f248b169d8ae7e9c Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 11 Dec 2024 16:40:42 +0200 Subject: [PATCH 006/115] update icqoracle protos --- proto/stride/icqoracle/icqoracle.proto | 24 +- proto/stride/icqoracle/query.proto | 4 +- proto/stride/icqoracle/tx.proto | 17 +- utils/utils.go | 13 +- x/icqoracle/client/cli/tx.go | 12 +- x/icqoracle/keeper/icq.go | 83 +++++-- x/icqoracle/keeper/icqcallbacks.go | 44 ---- x/icqoracle/keeper/keeper.go | 62 +---- x/icqoracle/keeper/msg_server.go | 20 +- x/icqoracle/keeper/query.go | 8 +- x/icqoracle/types/icqoracle.pb.go | 310 +++++++++++++++++++++---- x/icqoracle/types/keys.go | 6 + x/icqoracle/types/msgs.go | 32 ++- x/icqoracle/types/query.pb.go | 119 +++++++--- x/icqoracle/types/query.pb.gw.go | 66 ++---- x/icqoracle/types/tx.pb.go | 272 +++++++++++++++++++--- 16 files changed, 770 insertions(+), 322 deletions(-) delete mode 100644 x/icqoracle/keeper/icqcallbacks.go diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index 48dc2aad36..a3106ced79 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -8,24 +8,32 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; // TokenPrice stores latest price data for a token message TokenPrice { - // Token denom (e.g. "uatom", "uosmo") - string base_denom = 1; + // Token denom on its base chain (e.g. "uatom", "uosmo", "udym") + string denom = 1; - // Quote denom (e.g. ustrd, uusdc) - string quote_denom = 2; + // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + string base_denom = 2; + // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + string quote_denom = 3; + // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + string osmosis_base_denom = 4; + // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + string osmosis_quote_denom = 5; + // Pool ID on Osmosis + string osmosis_pool_id = 6; // Price in USDC or STRD - string price = 3 [ + string price = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Last update timestamp - google.protobuf.Timestamp updated_at = 4 + google.protobuf.Timestamp updated_at = 8 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // Whether there is a price query currently in progress - bool query_in_progress = 5; + bool query_in_progress = 9; } // OracleParams stores global oracle parameters @@ -48,7 +56,7 @@ message Params { (gogoproto.jsontag) = "update_interval_sec" ]; - // Max time before price is stale + // Max time before price is considered stale uint64 timeout_sec = 4 [ (gogoproto.moretags) = "yaml:\"timeout_sec\"", (gogoproto.jsontag) = "timeout_sec" diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index f782466370..3cab7f6aed 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -12,8 +12,7 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Query { // TokenPrice queries the current price for a specific token rpc TokenPrice(QueryTokenPriceRequest) returns (QueryTokenPriceResponse) { - option (google.api.http).get = - "/stride/icqoracle/v1beta1/price/{quote_denom}/{base_denom}"; + option (google.api.http).get = "/stride/icqoracle/v1beta1/price"; } // TokenPrices queries all token prices @@ -32,6 +31,7 @@ service Query { message QueryTokenPriceRequest { string base_denom = 1; string quote_denom = 2; + string pool_id = 3; } // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 2b5cd17730..bba1684b00 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -25,10 +25,17 @@ message MsgAddTokenPrice { option (amino.name) = "stride/x/icqoracle/MsgAddTokenPrice"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Token denom (e.g. "uatom", "uosmo") + + // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") string base_denom = 2; - // Quote denom (e.g. ustrd, uusdc) + // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") string quote_denom = 3; + // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + string osmosis_base_denom = 4; + // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + string osmosis_quote_denom = 5; + // Pool ID on Osmosis + string osmosis_pool_id = 6; } message MsgAddTokenPriceResponse {} @@ -40,10 +47,12 @@ message MsgRemoveTokenPrice { option (amino.name) = "stride/x/icqoracle/MsgRemoveTokenPrice"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Token denom (e.g. "uatom", "uosmo") + // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") string base_denom = 2; - // Quote denom (e.g. ustrd, uusdc) + // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") string quote_denom = 3; + // Pool ID on Osmosis + string osmosis_pool_id = 4; } message MsgRemoveTokenPriceResponse {} \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index 2589d84397..ada62b08a8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -20,6 +20,7 @@ import ( config "github.com/Stride-Labs/stride/v24/cmd/strided/config" icacallbacktypes "github.com/Stride-Labs/stride/v24/x/icacallbacks/types" + icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" recordstypes "github.com/Stride-Labs/stride/v24/x/records/types" ) @@ -233,9 +234,9 @@ func LogWithHostZone(chainId string, s string, a ...any) string { // Ex: // // | uosmo/ustrd | string -func LogWithPriceToken(baseDenom string, quoteDenom string, s string, a ...any) string { +func LogWithPriceToken(tokenPrice icqoracletypes.TokenPrice, s string, a ...any) string { msg := fmt.Sprintf(s, a...) - return fmt.Sprintf("| %-13s | %s/%s", baseDenom, quoteDenom, msg) + return fmt.Sprintf("| %s/%s/%s | %s", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, msg) } // Returns a log string with a chain Id and callback as a prefix @@ -243,9 +244,9 @@ func LogWithPriceToken(baseDenom string, quoteDenom string, s string, a ...any) // Format: // // | uosmo/ustrd | {CALLBACK_ID} {CALLBACK_TYPE} | string -func logCallbackWithPriceToken(baseDenom string, quoteDenom string, callbackId string, callbackType string, s string, a ...any) string { +func logCallbackWithPriceToken(tokenPrice icqoracletypes.TokenPrice, callbackId string, callbackType string, s string, a ...any) string { msg := fmt.Sprintf(s, a...) - return fmt.Sprintf("| %s/%s | %s %s | %s", baseDenom, quoteDenom, strings.ToUpper(callbackId), callbackType, msg) + return fmt.Sprintf("| %s/%s/%s | %s %s | %s", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, strings.ToUpper(callbackId), callbackType, msg) } // Returns a log string with a chain Id and callback as a prefix @@ -295,8 +296,8 @@ func LogICQCallbackWithHostZone(chainId string, callbackId string, s string, a . // Ex: // // | COSMOSHUB-4 | WITHDRAWALHOSTBALANCE ICQCALLBACK | string -func LogICQCallbackWithPriceToken(baseDenom string, quoteDenom string, callbackId string, s string, a ...any) string { - return logCallbackWithPriceToken(baseDenom, quoteDenom, callbackId, "ICQCALLBACK", s, a...) +func LogICQCallbackWithPriceToken(tokenPrice icqoracletypes.TokenPrice, callbackId string, s string, a ...any) string { + return logCallbackWithPriceToken(tokenPrice, callbackId, "ICQCALLBACK", s, a...) } // Returns a log header string with a dash padding on either side diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go index 5f19e2ca46..77e7073566 100644 --- a/x/icqoracle/client/cli/tx.go +++ b/x/icqoracle/client/cli/tx.go @@ -33,13 +33,13 @@ func GetTxCmd() *cobra.Command { func CmdAddTokenPrice() *cobra.Command { cmd := &cobra.Command{ - Use: "add-token-price [base-denom] [quote-denom]", + Use: "add-token-price [base-denom] [quote-denom] [osmosis-pool-id] [osmosis-base-denom] [osmosis-quote-denom]", Short: "Add a token to price tracking", Long: strings.TrimSpace( fmt.Sprintf(`Add a token to price tracking. Example: - $ %[1]s tx %[2]s add-token-price uatom uusdc --from admin + $ %[1]s tx %[2]s add-token-price uosmo uatom 123 uosmo ibc/... --from admin `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(2), @@ -53,6 +53,9 @@ Example: clientCtx.GetFromAddress().String(), args[0], args[1], + args[2], + args[3], + args[4], ) if err := msg.ValidateBasic(); err != nil { @@ -70,13 +73,13 @@ Example: func CmdRemoveTokenPrice() *cobra.Command { cmd := &cobra.Command{ - Use: "remove-token-price [base-denom] [quote-denom]", + Use: "remove-token-price [base-denom] [quote-denom] [osmosis-pool-id]", Short: "Remove a token from price tracking", Long: strings.TrimSpace( fmt.Sprintf(`Remove a token from price tracking. Example: - $ %[1]s tx %[2]s remove-token-price uatom uusdc --from admin + $ %[1]s tx %[2]s remove-token-price uatom uosmo 123 --from admin `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(2), @@ -90,6 +93,7 @@ Example: clientCtx.GetFromAddress().String(), args[0], args[1], + args[2], ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 550b504281..12af84052b 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -14,19 +14,56 @@ import ( icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" ) +const ( + ICQCallbackID_SpotPriceV2 = "spotpricev2" +) + +// ICQCallbacks wrapper struct for stakeibc keeper +type ICQCallback func(Keeper, sdk.Context, []byte, icqtypes.Query) error + +type ICQCallbacks struct { + k Keeper + callbacks map[string]ICQCallback +} + +var _ icqtypes.QueryCallbacks = ICQCallbacks{} + +func (k Keeper) ICQCallbackHandler() ICQCallbacks { + return ICQCallbacks{k, make(map[string]ICQCallback)} +} + +func (c ICQCallbacks) CallICQCallback(ctx sdk.Context, id string, args []byte, query icqtypes.Query) error { + return c.callbacks[id](c.k, ctx, args, query) +} + +func (c ICQCallbacks) HasICQCallback(id string) bool { + _, found := c.callbacks[id] + return found +} + +func (c ICQCallbacks) AddICQCallback(id string, fn interface{}) icqtypes.QueryCallbacks { + c.callbacks[id] = fn.(ICQCallback) + return c +} + +func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks { + return c. + AddICQCallback(ICQCallbackID_SpotPriceV2, ICQCallback(SpotPriceV2Callback)) +} + // Submits an ICQ to get a validator's shares to tokens rate func (k Keeper) SubmitSpotPriceV2CallbackICQ( ctx sdk.Context, tokenPrice types.TokenPrice, ) error { - k.Logger(ctx).Info(utils.LogWithPriceToken(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, "Submitting SpotPriceV2 ICQ")) + k.Logger(ctx).Info(utils.LogWithPriceToken(tokenPrice, "Submitting SpotPriceV2 ICQ")) params := k.GetParams(ctx) // Submit validator sharesToTokens rate ICQ // Considering this query is executed manually, we can be conservative with the timeout query := icqtypes.Query{ - Id: fmt.Sprintf("%s|%s-%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, ctx.BlockHeight()), // TODO fix? + Id: fmt.Sprintf("%s|%s|%s|%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, ctx.BlockHeight()), // TODO fix? ChainId: params.OsmosisChainId, ConnectionId: params.OsmosisConnectionId, QueryType: icqtypes.STAKING_STORE_QUERY_WITH_PROOF, // TODO fix @@ -38,51 +75,57 @@ func (k Keeper) SubmitSpotPriceV2CallbackICQ( TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, // TODO fix } if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, "Error submitting SpotPriceV2 ICQ, error '%s'", err.Error())) + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error submitting SpotPriceV2 ICQ, error '%s'", err.Error())) return err } - if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, true); err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, "Error updating queryInProgress=true, error '%s'", err.Error())) + if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice, true); err != nil { + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error updating queryInProgress=true, error '%s'", err.Error())) return err } return nil } -var queryIdRegex = regexp.MustCompile(`^(.+)\|(.+)-(\d+)$`) +var queryIdRegex = regexp.MustCompile(`^(.+)\|(.+)\|(\d+)\|(\d+)$`) // Helper function to parse the ID string -func ParseQueryID(id string) (baseDenom, quoteDenom, blockHeight string, ok bool) { +func parseQueryID(id string) (baseDenom, quoteDenom, poolId, blockHeight string, ok bool) { matches := queryIdRegex.FindStringSubmatch(id) - if len(matches) != 4 { - return "", "", "", false + if len(matches) != 5 { + return "", "", "", "", false } - return matches[1], matches[2], matches[3], true + return matches[1], matches[2], matches[3], matches[4], true } func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { - baseDenom, quoteDenom, _, ok := ParseQueryID(query.Id) + baseDenom, quoteDenom, poolId, _, ok := parseQueryID(query.Id) if !ok { return fmt.Errorf("unable to parse baseDenom and quoteDenom from queryId '%s'", query.Id) } - k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(baseDenom, quoteDenom, "SpotPriceV2", + tokenPrice := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: poolId, + } + + k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "SpotPriceV2", "Starting SpotPriceV2 ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) + tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) + if err != nil { + return errorsmod.Wrap(err, "unable to get current spot price") + } + // Unmarshal the query response args to determine the balance - spotPrice, err := icqkeeper.UnmarshalSpotPriceFromSpotPriceV2Query(k.cdc, args) + newSpotPrice, err := icqkeeper.UnmarshalSpotPriceFromSpotPriceV2Query(k.cdc, args) if err != nil { return errorsmod.Wrap(err, "unable to determine spot price from query response") } - tokenPrice := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, - Price: spotPrice, - UpdatedAt: ctx.BlockTime(), - QueryInProgress: false, - } + tokenPrice.Price = newSpotPrice + tokenPrice.QueryInProgress = false if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { return errorsmod.Wrap(err, "unable to update spot price from query response") diff --git a/x/icqoracle/keeper/icqcallbacks.go b/x/icqoracle/keeper/icqcallbacks.go deleted file mode 100644 index 251b4b39f2..0000000000 --- a/x/icqoracle/keeper/icqcallbacks.go +++ /dev/null @@ -1,44 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" -) - -const ( - ICQCallbackID_SpotPriceV2 = "spotpricev2" -) - -// ICQCallbacks wrapper struct for stakeibc keeper -type ICQCallback func(Keeper, sdk.Context, []byte, icqtypes.Query) error - -type ICQCallbacks struct { - k Keeper - callbacks map[string]ICQCallback -} - -var _ icqtypes.QueryCallbacks = ICQCallbacks{} - -func (k Keeper) ICQCallbackHandler() ICQCallbacks { - return ICQCallbacks{k, make(map[string]ICQCallback)} -} - -func (c ICQCallbacks) CallICQCallback(ctx sdk.Context, id string, args []byte, query icqtypes.Query) error { - return c.callbacks[id](c.k, ctx, args, query) -} - -func (c ICQCallbacks) HasICQCallback(id string) bool { - _, found := c.callbacks[id] - return found -} - -func (c ICQCallbacks) AddICQCallback(id string, fn interface{}) icqtypes.QueryCallbacks { - c.callbacks[id] = fn.(ICQCallback) - return c -} - -func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks { - return c. - AddICQCallback(ICQCallbackID_SpotPriceV2, ICQCallback(SpotPriceV2Callback)) -} diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 2b7527617e..a978557804 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -61,30 +61,11 @@ func (k Keeper) GetLastUpdateTime(ctx sdk.Context) (time.Time, error) { return time.Unix(0, nanos), nil } -// UpdatePrices queries and updates all token prices -func (k Keeper) UpdatePrices(ctx sdk.Context) error { - // Query prices from Osmosis via ICQ - prices, err := k.QueryOsmosisPrices(ctx) - if err != nil { - return err - } - - // Update stored prices - for _, price := range prices { - if err := k.SetTokenPrice(ctx, price); err != nil { - return err - } - } - - return nil -} - // SetTokenPrice stores price data for a token -func (k Keeper) SetTokenPrice(ctx sdk.Context, price types.TokenPrice) error { +func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { store := ctx.KVStore(k.storeKey) - key := []byte(fmt.Sprintf("%s/%s/%s", types.KeyPricePrefix, price.BaseDenom, price.QuoteDenom)) - - bz, err := k.cdc.Marshal(&price) + key := types.TokenPriceKey(tokenPrice.Denom, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + bz, err := k.cdc.Marshal(&tokenPrice) if err != nil { return err } @@ -94,14 +75,14 @@ func (k Keeper) SetTokenPrice(ctx sdk.Context, price types.TokenPrice) error { } // RemoveTokenPrice removes price data for a token -func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string) { +func (k Keeper) RemoveTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) { store := ctx.KVStore(k.storeKey) - key := []byte(fmt.Sprintf("%s/%s/%s", types.KeyPricePrefix, baseDenom, quoteDenom)) + key := types.TokenPriceKey(tokenPrice.Denom, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) store.Delete(key) } -func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, queryInProgress bool) error { - tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom) +func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, tokenPrice types.TokenPrice, queryInProgress bool) error { + tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) if err != nil { return err } @@ -116,13 +97,13 @@ func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, } // GetTokenPrice retrieves price data for a token -func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string) (types.TokenPrice, error) { +func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (types.TokenPrice, error) { store := ctx.KVStore(k.storeKey) - key := []byte(fmt.Sprintf("%s/%s/%s", types.KeyPricePrefix, baseDenom, quoteDenom)) + key := types.TokenPriceKey(tokenPrice.Denom, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) bz := store.Get(key) if bz == nil { - return types.TokenPrice{}, fmt.Errorf("price not found for base denom '%s' & quote denom '%s'", baseDenom, quoteDenom) + return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%s'", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) } var price types.TokenPrice @@ -148,26 +129,3 @@ func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { return prices } - -// QueryOsmosisPrices implements the ICQ price query -func (k Keeper) QueryOsmosisPrices(ctx sdk.Context) ([]types.TokenPrice, error) { - // TODO: Implement actual ICQ query to Osmosis - // This is a placeholder that returns mock data - mockPrices := []types.TokenPrice{ - { - BaseDenom: "uatom", - QuoteDenom: "ustrd", - Price: sdk.NewDec(10), - UpdatedAt: ctx.BlockTime(), - QueryInProgress: false, - }, - { - BaseDenom: "uosmo", - QuoteDenom: "ustrd", - Price: sdk.NewDec(5), - UpdatedAt: ctx.BlockTime(), - QueryInProgress: false, - }, - } - return mockPrices, nil -} diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index 2b4a64338f..409d682df3 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -29,11 +29,14 @@ func (ms msgServer) AddTokenPrice(goCtx context.Context, msg *types.MsgAddTokenP // TODO check admin tokenPrice := types.TokenPrice{ - BaseDenom: msg.BaseDenom, - QuoteDenom: msg.QuoteDenom, - UpdatedAt: time.Time{}, - Price: sdkmath.LegacyZeroDec(), - QueryInProgress: false, + BaseDenom: msg.BaseDenom, + QuoteDenom: msg.QuoteDenom, + OsmosisPoolId: msg.OsmosisPoolId, + OsmosisBaseDenom: msg.OsmosisBaseDenom, + OsmosisQuoteDenom: msg.OsmosisQuoteDenom, + UpdatedAt: time.Time{}, + Price: sdkmath.LegacyZeroDec(), + QueryInProgress: false, } err := ms.Keeper.SetTokenPrice(ctx, tokenPrice) @@ -50,7 +53,12 @@ func (ms msgServer) RemoveTokenPrice(goCtx context.Context, msg *types.MsgRemove // TODO check admin - ms.Keeper.RemoveTokenPrice(ctx, msg.BaseDenom, msg.QuoteDenom) + tokenPrice := types.TokenPrice{ + BaseDenom: msg.BaseDenom, + QuoteDenom: msg.QuoteDenom, + OsmosisPoolId: msg.OsmosisPoolId, + } + ms.Keeper.RemoveTokenPrice(ctx, tokenPrice) return &types.MsgRemoveTokenPriceResponse{}, nil } diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index bc6e5e75ec..395e1efc69 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -20,8 +20,12 @@ func (k Keeper) TokenPrice(goCtx context.Context, req *types.QueryTokenPriceRequ } ctx := sdk.UnwrapSDKContext(goCtx) - - price, err := k.GetTokenPrice(ctx, req.BaseDenom, req.QuoteDenom) + tokenPrice := types.TokenPrice{ + BaseDenom: req.BaseDenom, + QuoteDenom: req.QuoteDenom, + OsmosisPoolId: req.PoolId, + } + price, err := k.GetTokenPrice(ctx, tokenPrice) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 7a67819807..319e802171 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -30,16 +30,24 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // TokenPrice stores latest price data for a token type TokenPrice struct { - // Token denom (e.g. "uatom", "uosmo") - BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // Quote denom (e.g. ustrd, uusdc) - QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + // Token denom on its base chain (e.g. "uatom", "uosmo", "udym") + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + OsmosisBaseDenom string `protobuf:"bytes,4,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` + // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + OsmosisQuoteDenom string `protobuf:"bytes,5,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` + // Pool ID on Osmosis + OsmosisPoolId string `protobuf:"bytes,6,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` // Price in USDC or STRD - Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` + Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` // Last update timestamp - UpdatedAt time.Time `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + UpdatedAt time.Time `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` // Whether there is a price query currently in progress - QueryInProgress bool `protobuf:"varint,5,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` + QueryInProgress bool `protobuf:"varint,9,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` } func (m *TokenPrice) Reset() { *m = TokenPrice{} } @@ -75,6 +83,13 @@ func (m *TokenPrice) XXX_DiscardUnknown() { var xxx_messageInfo_TokenPrice proto.InternalMessageInfo +func (m *TokenPrice) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + func (m *TokenPrice) GetBaseDenom() string { if m != nil { return m.BaseDenom @@ -89,6 +104,27 @@ func (m *TokenPrice) GetQuoteDenom() string { return "" } +func (m *TokenPrice) GetOsmosisBaseDenom() string { + if m != nil { + return m.OsmosisBaseDenom + } + return "" +} + +func (m *TokenPrice) GetOsmosisQuoteDenom() string { + if m != nil { + return m.OsmosisQuoteDenom + } + return "" +} + +func (m *TokenPrice) GetOsmosisPoolId() string { + if m != nil { + return m.OsmosisPoolId + } + return "" +} + func (m *TokenPrice) GetUpdatedAt() time.Time { if m != nil { return m.UpdatedAt @@ -111,7 +147,7 @@ type Params struct { OsmosisConnectionId string `protobuf:"bytes,2,opt,name=osmosis_connection_id,json=osmosisConnectionId,proto3" json:"osmosis_connection_id" yaml:"osmosis_connection_id"` // Time between price updates UpdateIntervalSec uint64 `protobuf:"varint,3,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` - // Max time before price is stale + // Max time before price is considered stale TimeoutSec uint64 `protobuf:"varint,4,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec" yaml:"timeout_sec"` } @@ -184,39 +220,43 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 512 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xc1, 0x6f, 0xd3, 0x30, - 0x14, 0xc6, 0x1b, 0xd6, 0x4d, 0xab, 0x2b, 0xc1, 0xe6, 0x81, 0xa8, 0x0a, 0xc4, 0x55, 0x10, 0x52, - 0x85, 0x44, 0x22, 0x6d, 0x70, 0x18, 0x37, 0xb2, 0x09, 0xa9, 0xd2, 0x90, 0xaa, 0x74, 0x17, 0xb8, - 0x44, 0xae, 0x63, 0x52, 0x6b, 0x4d, 0x9c, 0xc6, 0xce, 0x44, 0x8f, 0xfc, 0x07, 0xfb, 0xb3, 0x76, - 0xdc, 0x11, 0x71, 0x30, 0xa8, 0xbd, 0xf5, 0xd8, 0x13, 0x47, 0x14, 0x3b, 0xad, 0xaa, 0xad, 0x37, - 0xfb, 0xf7, 0x7d, 0xfe, 0xde, 0x8b, 0xf3, 0x0c, 0x3a, 0x42, 0xe6, 0x2c, 0xa2, 0x1e, 0x23, 0x13, - 0x9e, 0x63, 0x32, 0xde, 0x58, 0xb9, 0x59, 0xce, 0x25, 0x87, 0x07, 0xc6, 0xe1, 0xae, 0x79, 0xfb, - 0x69, 0xcc, 0x63, 0xae, 0x45, 0xaf, 0x5c, 0x19, 0x5f, 0x1b, 0xc5, 0x9c, 0xc7, 0x63, 0xea, 0xe9, - 0xdd, 0xb0, 0xf8, 0xee, 0x49, 0x96, 0x50, 0x21, 0x71, 0x92, 0x19, 0x83, 0xf3, 0xcf, 0x02, 0xe0, - 0x92, 0x5f, 0xd1, 0xb4, 0x9f, 0x33, 0x42, 0xe1, 0x2b, 0x00, 0x86, 0x58, 0xd0, 0x30, 0xa2, 0x29, - 0x4f, 0x5a, 0x56, 0xc7, 0xea, 0x36, 0x82, 0x46, 0x49, 0xce, 0x4b, 0x00, 0x11, 0x68, 0x4e, 0x0a, - 0x2e, 0x57, 0xfa, 0x23, 0xad, 0x03, 0x8d, 0x8c, 0xe1, 0x14, 0xec, 0x66, 0x65, 0x50, 0x6b, 0xa7, - 0x94, 0xfc, 0xd7, 0xb7, 0x0a, 0xd5, 0x7e, 0x2b, 0xf4, 0x82, 0x70, 0x91, 0x70, 0x21, 0xa2, 0x2b, - 0x97, 0x71, 0x2f, 0xc1, 0x72, 0xe4, 0x5e, 0xd0, 0x18, 0x93, 0xe9, 0x39, 0x25, 0x81, 0x39, 0x01, - 0xcf, 0x00, 0x28, 0xb2, 0x08, 0x4b, 0x1a, 0x85, 0x58, 0xb6, 0xea, 0x1d, 0xab, 0xdb, 0x3c, 0x6e, - 0xbb, 0xa6, 0x7f, 0x77, 0xd5, 0xbf, 0x7b, 0xb9, 0xea, 0xdf, 0xdf, 0x2f, 0xb3, 0x6f, 0xfe, 0x20, - 0x2b, 0x68, 0x54, 0xe7, 0x3e, 0x49, 0xf8, 0x16, 0x1c, 0x4e, 0x0a, 0x9a, 0x4f, 0x43, 0x96, 0x86, - 0x59, 0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, 0xbb, 0xf6, 0x6b, 0x6e, 0xd7, 0xbe, 0x9d, 0xc4, - 0x4c, 0x8e, 0x8a, 0xa1, 0x4b, 0x78, 0xe2, 0x0d, 0xf4, 0xb0, 0xbf, 0xbb, 0xc0, 0x43, 0xe1, 0x55, - 0x4f, 0xe3, 0xfa, 0xf8, 0xbd, 0xf7, 0x63, 0xe3, 0x81, 0xc8, 0x69, 0x46, 0xc5, 0x70, 0x4f, 0xcf, - 0xc9, 0xc9, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x78, 0xcc, 0x04, 0x81, 0x41, 0x03, 0x00, 0x00, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x4f, 0x6f, 0xd3, 0x3e, + 0x18, 0xc7, 0x9b, 0xdf, 0xfe, 0xfc, 0x56, 0x4f, 0xb0, 0xcd, 0x1b, 0xa2, 0x2a, 0x10, 0x57, 0x41, + 0xa0, 0x09, 0x41, 0x22, 0x6d, 0x70, 0x18, 0x37, 0xb2, 0x09, 0xa9, 0xd2, 0x90, 0x4a, 0xb6, 0x0b, + 0x5c, 0x22, 0xd7, 0x31, 0x99, 0xb5, 0x24, 0x4e, 0x63, 0x67, 0xa2, 0x47, 0xde, 0xc1, 0x0e, 0xbc, + 0xa8, 0x1d, 0x77, 0x44, 0x1c, 0x02, 0x6a, 0x6f, 0x3d, 0xf6, 0x15, 0xa0, 0xd8, 0x49, 0x89, 0x46, + 0x6f, 0xf6, 0xf7, 0xf3, 0xf5, 0xd7, 0xf2, 0xe3, 0xe7, 0x01, 0x3d, 0x21, 0x33, 0x16, 0x50, 0x87, + 0x91, 0x11, 0xcf, 0x30, 0x89, 0x1a, 0x2b, 0x3b, 0xcd, 0xb8, 0xe4, 0x70, 0x5b, 0x3b, 0xec, 0x85, + 0xde, 0xdd, 0x0b, 0x79, 0xc8, 0x15, 0x74, 0xca, 0x95, 0xf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f, 0x0b, 0x04, 0x75, 0x6c, 0x43, 0xb4, 0x3c, 0x50, 0xed, + 0xce, 0x28, 0x71, 0x3f, 0xdc, 0x4c, 0x4c, 0xe3, 0x76, 0x62, 0x1a, 0xbf, 0x27, 0xa6, 0x71, 0x3d, + 0x35, 0x5b, 0xb7, 0x53, 0xb3, 0xf5, 0x63, 0x6a, 0xb6, 0x3e, 0x1f, 0x86, 0x4c, 0x5e, 0xe4, 0x43, + 0x9b, 0xf0, 0xd8, 0x39, 0x53, 0x83, 0xf8, 0xea, 0x14, 0x0f, 0x85, 0x53, 0x8d, 0xed, 0xd5, 0xc1, + 0x6b, 0xe7, 0x6b, 0x63, 0x78, 0xe5, 0x38, 0xa5, 0x62, 0xb8, 0xae, 0xfa, 0xe4, 0xf0, 0x4f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x56, 0xd4, 0xfb, 0xf2, 0xdd, 0x03, 0x00, 0x00, } func (m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -247,7 +287,7 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x28 + dAtA[i] = 0x48 } n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) if err1 != nil { @@ -256,7 +296,7 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintIcqoracle(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x42 { size := m.Price.Size() i -= size @@ -266,19 +306,47 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintIcqoracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x3a + if len(m.OsmosisPoolId) > 0 { + i -= len(m.OsmosisPoolId) + copy(dAtA[i:], m.OsmosisPoolId) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisPoolId))) + i-- + dAtA[i] = 0x32 + } + if len(m.OsmosisQuoteDenom) > 0 { + i -= len(m.OsmosisQuoteDenom) + copy(dAtA[i:], m.OsmosisQuoteDenom) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisQuoteDenom))) + i-- + dAtA[i] = 0x2a + } + if len(m.OsmosisBaseDenom) > 0 { + i -= len(m.OsmosisBaseDenom) + copy(dAtA[i:], m.OsmosisBaseDenom) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisBaseDenom))) + i-- + dAtA[i] = 0x22 + } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) copy(dAtA[i:], m.QuoteDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.QuoteDenom))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.BaseDenom) > 0 { i -= len(m.BaseDenom) copy(dAtA[i:], m.BaseDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.BaseDenom))) i-- + dAtA[i] = 0x12 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.Denom))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -348,6 +416,10 @@ func (m *TokenPrice) Size() (n int) { } var l int _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } l = len(m.BaseDenom) if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) @@ -356,6 +428,18 @@ func (m *TokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) } + l = len(m.OsmosisBaseDenom) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } + l = len(m.OsmosisQuoteDenom) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } + l = len(m.OsmosisPoolId) + if l > 0 { + n += 1 + l + sovIcqoracle(uint64(l)) + } l = m.Price.Size() n += 1 + l + sovIcqoracle(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) @@ -425,6 +509,38 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) } @@ -456,7 +572,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.BaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", wireType) } @@ -488,7 +604,103 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisBaseDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisBaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisQuoteDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + 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 ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) } @@ -522,7 +734,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) } @@ -555,7 +767,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", wireType) } diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 311b4ce67d..32dc2c8490 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -1,5 +1,7 @@ package types +import fmt "fmt" + const ( ModuleName = "icqoracle" @@ -13,3 +15,7 @@ const ( KeyPricePrefix = "price" KeyLastUpdateTime = "last_update_time" ) + +func TokenPriceKey(denom, baseDenom, quoteDenom, poolId string) []byte { + return []byte(fmt.Sprintf("%s%s%s%s%s", KeyPricePrefix, denom, baseDenom, quoteDenom, poolId)) +} diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 5375463b74..22bd5379ee 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -27,11 +27,14 @@ var ( // MsgClaim // ---------------------------------------------- -func NewMsgAddTokenPrice(sender, baseDenom, quoteDenom string) *MsgAddTokenPrice { +func NewMsgAddTokenPrice(sender, baseDenom, quoteDenom, poolId, osmosisBaseDenom, osmosisQuoteDenom string) *MsgAddTokenPrice { return &MsgAddTokenPrice{ - Sender: sender, - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, + Sender: sender, + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: poolId, + OsmosisBaseDenom: osmosisBaseDenom, + OsmosisQuoteDenom: osmosisQuoteDenom, } } @@ -66,6 +69,15 @@ func (msg *MsgAddTokenPrice) ValidateBasic() error { if msg.QuoteDenom == "" { return errors.New("quote-denom must be specified") } + if msg.OsmosisPoolId == "" { + return errors.New("osmosis-pool-id must be specified") + } + if msg.OsmosisBaseDenom == "" { + return errors.New("osmosis-base-denom must be specified") + } + if msg.OsmosisQuoteDenom == "" { + return errors.New("osmosis-quote-denom must be specified") + } return nil } @@ -74,11 +86,12 @@ func (msg *MsgAddTokenPrice) ValidateBasic() error { // MsgRemoveTokenPrice // ---------------------------------------------- -func NewMsgRemoveTokenPrice(sender, baseDenom, quoteDenom string) *MsgRemoveTokenPrice { +func NewMsgRemoveTokenPrice(sender, baseDenom, quoteDenom, osmosisPoolId string) *MsgRemoveTokenPrice { return &MsgRemoveTokenPrice{ - Sender: sender, - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, + Sender: sender, + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: osmosisPoolId, } } @@ -113,6 +126,9 @@ func (msg *MsgRemoveTokenPrice) ValidateBasic() error { if msg.QuoteDenom == "" { return errors.New("quote-denom must be specified") } + if msg.OsmosisPoolId == "" { + return errors.New("osmosis-pool-id must be specified") + } return nil } diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 61610cdf16..140a918d6e 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -35,6 +35,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QueryTokenPriceRequest struct { BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + PoolId string `protobuf:"bytes,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` } func (m *QueryTokenPriceRequest) Reset() { *m = QueryTokenPriceRequest{} } @@ -84,6 +85,13 @@ func (m *QueryTokenPriceRequest) GetQuoteDenom() string { return "" } +func (m *QueryTokenPriceRequest) GetPoolId() string { + if m != nil { + return m.PoolId + } + return "" +} + // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC // method type QueryTokenPriceResponse struct { @@ -325,40 +333,40 @@ func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_ var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ // 532 bytes of a gzipped FileDescriptorPro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, 0x79, 0xa5, 0x87, 0x3e, + 0x58, 0x00, 0x8b, 0xc9, 0x50, 0xa7, 0x2a, 0xf0, 0xf7, 0x07, 0xe7, 0xde, 0xda, 0x80, 0xa9, 0x5d, + 0xfa, 0x7b, 0xef, 0xbf, 0xfd, 0xfa, 0xbc, 0x75, 0x0d, 0xb5, 0x70, 0xe5, 0x0f, 0x34, 0x7f, 0xe9, + 0xaa, 0xfb, 0x47, 0x0b, 0xec, 0xa5, 0x1d, 0xa1, 0xf5, 0x3d, 0xca, 0x80, 0xdc, 0xfd, 0x4d, 0xa8, + 0xc6, 0x4f, 0x47, 0xf9, 0xf1, 0x51, 0x7b, 0x8d, 0x1f, 0x8e, 0xde, 0x41, 0x43, 0xe7, 0x87, 0xae, + 0xff, 0x43, 0x7f, 0x65, 0x4d, 0xee, 0x8d, 0x35, 0xac, 0xff, 0x30, 0xa0, 0xd7, 0x76, 0x74, 0x3a, + 0xf5, 0xac, 0xb3, 0xa9, 0x67, 0xfd, 0x9c, 0x7a, 0xd6, 0xa7, 0x99, 0x57, 0x3b, 0x9b, 0x79, 0xb5, + 0xef, 0x33, 0xaf, 0xf6, 0xf2, 0x30, 0x4e, 0xc4, 0xeb, 0x49, 0x18, 0x44, 0x6c, 0x8c, 0x9f, 0x2b, + 0x95, 0xdb, 0x4f, 0x49, 0xc8, 0x4b, 0xc5, 0xe3, 0xee, 0x1d, 0xfc, 0x76, 0x49, 0x57, 0x9c, 0x64, + 0x94, 0x87, 0x0d, 0xf5, 0x19, 0x39, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xe5, 0xea, 0x8a, 0x44, + 0xfa, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -539,6 +547,13 @@ func (m *QueryTokenPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if len(m.PoolId) > 0 { + i -= len(m.PoolId) + copy(dAtA[i:], m.PoolId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PoolId))) + i-- + dAtA[i] = 0x1a + } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) copy(dAtA[i:], m.QuoteDenom) @@ -754,6 +769,10 @@ func (m *QueryTokenPriceRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.PoolId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -919,6 +938,38 @@ func (m *QueryTokenPriceRequest) Unmarshal(dAtA []byte) error { } m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", 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.PoolId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/icqoracle/types/query.pb.gw.go b/x/icqoracle/types/query.pb.gw.go index 6ca0bf2850..2f763bde64 100644 --- a/x/icqoracle/types/query.pb.gw.go +++ b/x/icqoracle/types/query.pb.gw.go @@ -33,37 +33,19 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +var ( + filter_Query_TokenPrice_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + func request_Query_TokenPrice_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryTokenPriceRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["quote_denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "quote_denom") - } - - protoReq.QuoteDenom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "quote_denom", err) - } - - val, ok = pathParams["base_denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "base_denom") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.BaseDenom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "base_denom", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TokenPrice_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.TokenPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -75,33 +57,11 @@ func local_request_Query_TokenPrice_0(ctx context.Context, marshaler runtime.Mar var protoReq QueryTokenPriceRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["quote_denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "quote_denom") - } - - protoReq.QuoteDenom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "quote_denom", err) - } - - val, ok = pathParams["base_denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "base_denom") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.BaseDenom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "base_denom", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TokenPrice_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.TokenPrice(ctx, &protoReq) @@ -343,7 +303,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"stride", "icqoracle", "v1beta1", "price", "quote_denom", "base_denom"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "price"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index f7ca6ae31c..fa1140be1f 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -33,10 +33,16 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgAddTokenPrice defines the message for adding a new token to track prices type MsgAddTokenPrice struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // Token denom (e.g. "uatom", "uosmo") + // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // Quote denom (e.g. ustrd, uusdc) + // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + OsmosisBaseDenom string `protobuf:"bytes,4,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` + // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + OsmosisQuoteDenom string `protobuf:"bytes,5,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` + // Pool ID on Osmosis + OsmosisPoolId string `protobuf:"bytes,6,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } func (m *MsgAddTokenPrice) Reset() { *m = MsgAddTokenPrice{} } @@ -93,6 +99,27 @@ func (m *MsgAddTokenPrice) GetQuoteDenom() string { return "" } +func (m *MsgAddTokenPrice) GetOsmosisBaseDenom() string { + if m != nil { + return m.OsmosisBaseDenom + } + return "" +} + +func (m *MsgAddTokenPrice) GetOsmosisQuoteDenom() string { + if m != nil { + return m.OsmosisQuoteDenom + } + return "" +} + +func (m *MsgAddTokenPrice) GetOsmosisPoolId() string { + if m != nil { + return m.OsmosisPoolId + } + return "" +} + type MsgAddTokenPriceResponse struct { } @@ -133,10 +160,12 @@ var xxx_messageInfo_MsgAddTokenPriceResponse proto.InternalMessageInfo // tracking type MsgRemoveTokenPrice struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // Token denom (e.g. "uatom", "uosmo") + // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // Quote denom (e.g. ustrd, uusdc) + // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + // Pool ID on Osmosis + OsmosisPoolId string `protobuf:"bytes,4,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } func (m *MsgRemoveTokenPrice) Reset() { *m = MsgRemoveTokenPrice{} } @@ -193,6 +222,13 @@ func (m *MsgRemoveTokenPrice) GetQuoteDenom() string { return "" } +func (m *MsgRemoveTokenPrice) GetOsmosisPoolId() string { + if m != nil { + return m.OsmosisPoolId + } + return "" +} + type MsgRemoveTokenPriceResponse struct { } @@ -239,32 +275,36 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 395 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x2e, 0x29, 0xca, - 0x4c, 0x49, 0xd5, 0xcf, 0x4c, 0x2e, 0xcc, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0xa9, 0xd0, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x48, 0xe9, 0xc1, 0xa5, 0xa4, 0xc4, 0x93, 0xf3, - 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, 0xa9, 0x94, - 0x60, 0x62, 0x6e, 0x66, 0x5e, 0xbe, 0x3e, 0x98, 0x84, 0x0a, 0x49, 0x42, 0xd4, 0xc6, 0x83, 0x79, - 0xfa, 0x10, 0x0e, 0x44, 0x4a, 0x69, 0x27, 0x23, 0x97, 0x80, 0x6f, 0x71, 0xba, 0x63, 0x4a, 0x4a, - 0x48, 0x7e, 0x76, 0x6a, 0x5e, 0x40, 0x51, 0x66, 0x72, 0xaa, 0x90, 0x01, 0x17, 0x5b, 0x71, 0x6a, - 0x5e, 0x4a, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, - 0x50, 0x6d, 0x8e, 0x29, 0x29, 0x45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xf7, 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, 0x8c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, - 0x73, 0xf5, 0x83, 0xc1, 0x26, 0xeb, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0x43, 0xb4, 0xcc, 0xc8, - 0x04, 0x25, 0x54, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x09, 0xdd, 0x18, 0x10, 0x00, - 0x00, 0xff, 0xff, 0x9f, 0xce, 0x8b, 0x45, 0x5e, 0x03, 0x00, 0x00, + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x93, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0x73, 0xfd, 0x13, 0xa9, 0x2f, 0xaa, 0x48, 0x5d, 0x24, 0x5c, 0xa3, 0x1a, 0x64, 0x44, + 0x85, 0x22, 0xe2, 0x83, 0x06, 0x31, 0xb0, 0x35, 0x62, 0x41, 0x22, 0x52, 0x49, 0x99, 0x58, 0xac, + 0xc4, 0x77, 0x72, 0x4f, 0xc4, 0x7e, 0x53, 0xbf, 0x6e, 0x54, 0x36, 0xc4, 0xc8, 0xc4, 0x47, 0xc9, + 0xc0, 0xce, 0xca, 0x58, 0xb1, 0xc0, 0x88, 0x92, 0x21, 0x5f, 0x03, 0xe5, 0x7c, 0x2e, 0x89, 0xb1, + 0x04, 0x5b, 0x97, 0x44, 0xf7, 0x3c, 0xbf, 0xf7, 0x39, 0xdd, 0x73, 0x67, 0xd8, 0xa3, 0x2c, 0x55, + 0x42, 0x72, 0x15, 0x9e, 0x61,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a, 0x23, 0x7d, 0x9a, 0x4f, + 0x9a, 0xf7, 0xcd, 0x85, 0x5c, 0x2c, 0x5d, 0x49, 0xb9, 0x2c, 0xcf, 0x01, 0xbb, 0xac, 0xf5, 0x24, + 0x8d, 0x30, 0x21, 0xe9, 0xcd, 0x19, 0xec, 0x76, 0x29, 0xea, 0xc9, 0x18, 0xc7, 0xf2, 0x5a, 0x0b, + 0xae, 0xa8, 0x60, 0xa3, 0xaa, 0x82, 0x67, 0xa5, 0x0a, 0x0e, 0xaa, 0x2b, 0x28, 0x9f, 0xc8, 0xdb, + 0x87, 0x3b, 0x15, 0x72, 0x51, 0xc4, 0xe1, 0x0f, 0x06, 0xeb, 0x5d, 0x8a, 0xac, 0x00, 0xb6, 0x57, + 0x9f, 0x9a, 0xe7, 0x97, 0x5f, 0xb6, 0x5f, 0x6e, 0xd3, 0x69, 0xfe, 0x9b, 0x29, 0x36, 0xb2, 0x4e, + 0xa1, 0xf1, 0x57, 0xdb, 0x0f, 0x2a, 0xe7, 0xcb, 0x98, 0xd3, 0xfa, 0x2f, 0xac, 0xd8, 0xc9, 0xd9, + 0xfc, 0x30, 0x9f, 0x34, 0x59, 0xa7, 0xfb, 0x6d, 0xea, 0xb2, 0xcb, 0xa9, 0xcb, 0x7e, 0x4d, 0x5d, + 0xf6, 0x79, 0xe6, 0xd6, 0x2e, 0x67, 0x6e, 0xed, 0xe7, 0xcc, 0xad, 0xbd, 0x6d, 0x47, 0x2a, 0x3b, + 0x3d, 0x1f, 0xf8, 0x21, 0xc6, 0xfc, 0x44, 0x27, 0xb7, 0x5e, 0xf5, 0x07, 0xc4, 0x4d, 0xa3, 0xe3, + 0xc3, 0xa7, 0x2b, 0xad, 0x66, 0xef, 0x47, 0x92, 0x06, 0x75, 0xfd, 0x59, 0xb6, 0x7f, 0x07, 0x00, + 0x00, 0xff, 0xff, 0xdc, 0x6d, 0x69, 0x4f, 0x0c, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -407,6 +447,27 @@ func (m *MsgAddTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.OsmosisPoolId) > 0 { + i -= len(m.OsmosisPoolId) + copy(dAtA[i:], m.OsmosisPoolId) + i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisPoolId))) + i-- + dAtA[i] = 0x32 + } + if len(m.OsmosisQuoteDenom) > 0 { + i -= len(m.OsmosisQuoteDenom) + copy(dAtA[i:], m.OsmosisQuoteDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisQuoteDenom))) + i-- + dAtA[i] = 0x2a + } + if len(m.OsmosisBaseDenom) > 0 { + i -= len(m.OsmosisBaseDenom) + copy(dAtA[i:], m.OsmosisBaseDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisBaseDenom))) + i-- + dAtA[i] = 0x22 + } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) copy(dAtA[i:], m.QuoteDenom) @@ -474,6 +535,13 @@ func (m *MsgRemoveTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.OsmosisPoolId) > 0 { + i -= len(m.OsmosisPoolId) + copy(dAtA[i:], m.OsmosisPoolId) + i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisPoolId))) + i-- + dAtA[i] = 0x22 + } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) copy(dAtA[i:], m.QuoteDenom) @@ -550,6 +618,18 @@ func (m *MsgAddTokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.OsmosisBaseDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.OsmosisQuoteDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.OsmosisPoolId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -580,6 +660,10 @@ func (m *MsgRemoveTokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.OsmosisPoolId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -723,6 +807,102 @@ func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { } m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisBaseDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisBaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisQuoteDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -919,6 +1099,38 @@ func (m *MsgRemoveTokenPrice) Unmarshal(dAtA []byte) error { } m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From ccf28e332aed1e3796045483e314728d1f421aa1 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 11 Dec 2024 17:22:46 +0200 Subject: [PATCH 007/115] implement icqoracle query params + sanity checks before callback logic --- proto/stride/icqoracle/icqoracle.proto | 35 ++-- x/icqoracle/keeper/genesis.go | 4 +- x/icqoracle/keeper/icq.go | 127 ++++++------- x/icqoracle/keeper/keeper.go | 6 +- x/icqoracle/keeper/msg_server.go | 2 +- x/icqoracle/types/icqoracle.pb.go | 243 ++++++++++++------------- x/icqoracle/types/keys.go | 4 +- x/icqoracle/types/msgs.go | 9 +- x/interchainquery/keeper/queries.go | 1 + x/interchainquery/types/keys.go | 21 ++- 10 files changed, 225 insertions(+), 227 deletions(-) diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index a3106ced79..e7fd8cd5ff 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -8,32 +8,29 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; // TokenPrice stores latest price data for a token message TokenPrice { - // Token denom on its base chain (e.g. "uatom", "uosmo", "udym") - string denom = 1; - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") - string base_denom = 2; + string base_denom = 1; // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") - string quote_denom = 3; + string quote_denom = 2; // Token denom on Osmosis (e.g. "uosmo", "ibc/...") - string osmosis_base_denom = 4; + string osmosis_base_denom = 3; // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") - string osmosis_quote_denom = 5; + string osmosis_quote_denom = 4; // Pool ID on Osmosis - string osmosis_pool_id = 6; + string osmosis_pool_id = 5; - // Price in USDC or STRD - string price = 7 [ + // Spot price of base_denom denominated in quote_denom + string spot_price = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Last update timestamp - google.protobuf.Timestamp updated_at = 8 + google.protobuf.Timestamp updated_at = 7 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - // Whether there is a price query currently in progress - bool query_in_progress = 9; + // Whether there is a spot price query currently in progress + bool query_in_progress = 8; } // OracleParams stores global oracle parameters @@ -57,8 +54,14 @@ message Params { ]; // Max time before price is considered stale - uint64 timeout_sec = 4 [ - (gogoproto.moretags) = "yaml:\"timeout_sec\"", - (gogoproto.jsontag) = "timeout_sec" + uint64 price_stale_timeout_sec = 4 [ + (gogoproto.moretags) = "yaml:\"price_stale_timeout_sec\"", + (gogoproto.jsontag) = "price_stale_timeout_sec" + ]; + + // ICQ timeout + uint64 icq_timeout_sec = 5 [ + (gogoproto.moretags) = "yaml:\"icq_timeout_sec\"", + (gogoproto.jsontag) = "icq_timeout_sec" ]; } diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go index 8711a0ca71..c742a9e5cf 100644 --- a/x/icqoracle/keeper/genesis.go +++ b/x/icqoracle/keeper/genesis.go @@ -10,7 +10,9 @@ import ( func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { k.SetParams(ctx, genState.Params) for _, tokenPrice := range genState.TokenPrices { - k.SetTokenPrice(ctx, tokenPrice) + if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { + panic(err) + } } } diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 12af84052b..af6e3c27bf 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -1,8 +1,10 @@ package keeper import ( + "encoding/hex" "fmt" "regexp" + "strconv" "time" errorsmod "cosmossdk.io/errors" @@ -60,19 +62,30 @@ func (k Keeper) SubmitSpotPriceV2CallbackICQ( params := k.GetParams(ctx) - // Submit validator sharesToTokens rate ICQ - // Considering this query is executed manually, we can be conservative with the timeout + osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) + if err != nil { + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error converting osmosis pool id '%s' to uint64, error '%s'", tokenPrice.OsmosisPoolId, err.Error())) + return err + } + + tokenPriceBz, err := k.cdc.Marshal(&tokenPrice) + if err != nil { + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error serializing tokenPrice '%+v' to bytes, error '%s'", tokenPrice, err.Error())) + return err + } + + queryId := fmt.Sprintf("%s|%s|%s|%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, ctx.BlockHeight()) query := icqtypes.Query{ - Id: fmt.Sprintf("%s|%s|%s|%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, ctx.BlockHeight()), // TODO fix? + Id: queryId, ChainId: params.OsmosisChainId, ConnectionId: params.OsmosisConnectionId, - QueryType: icqtypes.STAKING_STORE_QUERY_WITH_PROOF, // TODO fix - RequestData: []byte{}, // TODO fix + QueryType: icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, + RequestData: icqtypes.FormatOsmosisKeyPool(osmosisPoolId), CallbackModule: types.ModuleName, - CallbackId: "banana", // TODO fix - CallbackData: []byte{}, // TODO fix - TimeoutDuration: 10 * time.Minute, // TODO fix - TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, // TODO fix + CallbackId: queryId, + CallbackData: tokenPriceBz, + TimeoutDuration: time.Duration(params.IcqTimeoutSec) * time.Second, + TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, } if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error submitting SpotPriceV2 ICQ, error '%s'", err.Error())) @@ -99,15 +112,40 @@ func parseQueryID(id string) (baseDenom, quoteDenom, poolId, blockHeight string, } func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { + // TODO is this check even needed? + if query.Id != query.CallbackId { + return fmt.Errorf("query.Id ('%s') != query.CallbackId ('%s')", query.Id, query.CallbackId) + } + baseDenom, quoteDenom, poolId, _, ok := parseQueryID(query.Id) if !ok { - return fmt.Errorf("unable to parse baseDenom and quoteDenom from queryId '%s'", query.Id) + return fmt.Errorf("Error parsing baseDenom and quoteDenom from queryId '%s'", query.Id) } - tokenPrice := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, - OsmosisPoolId: poolId, + var tokenPrice types.TokenPrice + if err := k.cdc.Unmarshal(query.CallbackData, &tokenPrice); err != nil { + return fmt.Errorf("Error deserializing query.CallbackData '%s' as TokenPrice", hex.EncodeToString(query.CallbackData)) + } + + // TODO is this check even needed? + if tokenPrice.BaseDenom != baseDenom { + return fmt.Errorf("tokenPrice.BaseDenom ('%s') != baseDenom ('%s')", tokenPrice.BaseDenom, baseDenom) + } + + // TODO is this check even needed? + if tokenPrice.QuoteDenom != quoteDenom { + return fmt.Errorf("tokenPrice.QuoteDenom ('%s') != quoteDenom ('%s')", tokenPrice.QuoteDenom, quoteDenom) + } + + // TODO is this check even needed? + if tokenPrice.OsmosisPoolId != poolId { + return fmt.Errorf("tokenPrice.OsmosisPoolId ('%s') != poolId ('%s')", tokenPrice.OsmosisPoolId, poolId) + } + + // TODO review this + // this should never happen + if !tokenPrice.QueryInProgress { + return nil } k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "SpotPriceV2", @@ -115,74 +153,21 @@ func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes. tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) if err != nil { - return errorsmod.Wrap(err, "unable to get current spot price") + return errorsmod.Wrap(err, "Error getting current spot price") } // Unmarshal the query response args to determine the balance newSpotPrice, err := icqkeeper.UnmarshalSpotPriceFromSpotPriceV2Query(k.cdc, args) if err != nil { - return errorsmod.Wrap(err, "unable to determine spot price from query response") + return errorsmod.Wrap(err, "Error determining spot price from query response") } - tokenPrice.Price = newSpotPrice + tokenPrice.SpotPrice = newSpotPrice tokenPrice.QueryInProgress = false if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { - return errorsmod.Wrap(err, "unable to update spot price from query response") + return errorsmod.Wrap(err, "Error updating spot price from query response") } return nil - - // k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_FeeBalance, - // "Query response - Fee Balance: %v %s", feeBalanceAmount, hostZone.HostDenom)) - - // // Confirm the balance is greater than zero - // if feeBalanceAmount.LTE(sdkmath.ZeroInt()) { - // k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_FeeBalance, - // "No balance to transfer for address: %s, balance: %v", hostZone.FeeIcaAddress, feeBalanceAmount)) - // return nil - // } - - // // Confirm the fee account has been initiated - // if hostZone.FeeIcaAddress == "" { - // return errorsmod.Wrapf(types.ErrICAAccountNotFound, "no fee account found for %s", chainId) - // } - - // // The ICA and transfer should both timeout before the end of the epoch - // timeout, err := k.GetICATimeoutNanos(ctx, epochtypes.STRIDE_EPOCH) - // if err != nil { - // return errorsmod.Wrapf(err, "Failed to get ICATimeout from %s epoch", epochtypes.STRIDE_EPOCH) - // } - - // // get counterparty chain's transfer channel - // transferChannel, found := k.IBCKeeper.ChannelKeeper.GetChannel(ctx, transfertypes.PortID, hostZone.TransferChannelId) - // if !found { - // return errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "transfer channel %s not found", hostZone.TransferChannelId) - // } - // counterpartyChannelId := transferChannel.Counterparty.ChannelId - - // // Prepare a MsgTransfer from the fee account to the rewards collector account - // rewardsCoin := sdk.NewCoin(hostZone.HostDenom, feeBalanceAmount) - // rewardsCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() - // transferMsg := ibctypes.NewMsgTransfer( - // transfertypes.PortID, - // counterpartyChannelId, - // rewardsCoin, - // hostZone.FeeIcaAddress, - // rewardsCollectorAddress.String(), - // clienttypes.Height{}, - // timeout, - // "", - // ) - - // msgs := []proto.Message{transferMsg} - // k.Logger(ctx).Info(utils.LogICQCallbackWithHostZone(chainId, ICQCallbackID_FeeBalance, - // "Preparing MsgTransfer of %v from the fee account to the rewards collector module account (for commission)", rewardsCoin.String())) - - // // Send the transaction through SubmitTx - // if _, err := k.SubmitTxsStrideEpoch(ctx, hostZone.ConnectionId, msgs, types.ICAAccountType_FEE, ICACallbackID_Reinvest, nil); err != nil { - // return errorsmod.Wrapf(types.ErrICATxFailed, "Failed to SubmitTxs, Messages: %v, err: %s", msgs, err.Error()) - // } - - // return nil } diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index a978557804..faf00b740c 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -64,7 +64,7 @@ func (k Keeper) GetLastUpdateTime(ctx sdk.Context) (time.Time, error) { // SetTokenPrice stores price data for a token func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { store := ctx.KVStore(k.storeKey) - key := types.TokenPriceKey(tokenPrice.Denom, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) bz, err := k.cdc.Marshal(&tokenPrice) if err != nil { return err @@ -77,7 +77,7 @@ func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) erro // RemoveTokenPrice removes price data for a token func (k Keeper) RemoveTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) { store := ctx.KVStore(k.storeKey) - key := types.TokenPriceKey(tokenPrice.Denom, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) store.Delete(key) } @@ -99,7 +99,7 @@ func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, tokenPrice types.T // GetTokenPrice retrieves price data for a token func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (types.TokenPrice, error) { store := ctx.KVStore(k.storeKey) - key := types.TokenPriceKey(tokenPrice.Denom, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) bz := store.Get(key) if bz == nil { diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index 409d682df3..d60cca7c3d 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -35,7 +35,7 @@ func (ms msgServer) AddTokenPrice(goCtx context.Context, msg *types.MsgAddTokenP OsmosisBaseDenom: msg.OsmosisBaseDenom, OsmosisQuoteDenom: msg.OsmosisQuoteDenom, UpdatedAt: time.Time{}, - Price: sdkmath.LegacyZeroDec(), + SpotPrice: sdkmath.LegacyZeroDec(), QueryInProgress: false, } diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 319e802171..3a52ac9335 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -30,24 +30,22 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // TokenPrice stores latest price data for a token type TokenPrice struct { - // Token denom on its base chain (e.g. "uatom", "uosmo", "udym") - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") - BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") - QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` // Token denom on Osmosis (e.g. "uosmo", "ibc/...") - OsmosisBaseDenom string `protobuf:"bytes,4,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` + OsmosisBaseDenom string `protobuf:"bytes,3,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") - OsmosisQuoteDenom string `protobuf:"bytes,5,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` + OsmosisQuoteDenom string `protobuf:"bytes,4,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,6,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` - // Price in USDC or STRD - Price cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=price,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price"` + OsmosisPoolId string `protobuf:"bytes,5,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + // Spot price of base_denom denominated in quote_denom + SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` // Last update timestamp - UpdatedAt time.Time `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` - // Whether there is a price query currently in progress - QueryInProgress bool `protobuf:"varint,9,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` + UpdatedAt time.Time `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + // Whether there is a spot price query currently in progress + QueryInProgress bool `protobuf:"varint,8,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` } func (m *TokenPrice) Reset() { *m = TokenPrice{} } @@ -83,13 +81,6 @@ func (m *TokenPrice) XXX_DiscardUnknown() { var xxx_messageInfo_TokenPrice proto.InternalMessageInfo -func (m *TokenPrice) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - func (m *TokenPrice) GetBaseDenom() string { if m != nil { return m.BaseDenom @@ -148,7 +139,9 @@ type Params struct { // Time between price updates UpdateIntervalSec uint64 `protobuf:"varint,3,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` // Max time before price is considered stale - TimeoutSec uint64 `protobuf:"varint,4,opt,name=timeout_sec,json=timeoutSec,proto3" json:"timeout_sec" yaml:"timeout_sec"` + PriceStaleTimeoutSec uint64 `protobuf:"varint,4,opt,name=price_stale_timeout_sec,json=priceStaleTimeoutSec,proto3" json:"price_stale_timeout_sec" yaml:"price_stale_timeout_sec"` + // ICQ timeout + IcqTimeoutSec uint64 `protobuf:"varint,5,opt,name=icq_timeout_sec,json=icqTimeoutSec,proto3" json:"icq_timeout_sec" yaml:"icq_timeout_sec"` } func (m *Params) Reset() { *m = Params{} } @@ -205,9 +198,16 @@ func (m *Params) GetUpdateIntervalSec() uint64 { return 0 } -func (m *Params) GetTimeoutSec() uint64 { +func (m *Params) GetPriceStaleTimeoutSec() uint64 { if m != nil { - return m.TimeoutSec + return m.PriceStaleTimeoutSec + } + return 0 +} + +func (m *Params) GetIcqTimeoutSec() uint64 { + if m != nil { + return m.IcqTimeoutSec } return 0 } @@ -220,43 +220,46 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 572 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x4f, 0x6f, 0xd3, 0x3e, - 0x18, 0xc7, 0x9b, 0xdf, 0xfe, 0xfc, 0x56, 0x4f, 0xb0, 0xcd, 0x1b, 0xa2, 0x2a, 0x10, 0x57, 0x41, - 0xa0, 0x09, 0x41, 0x22, 0x6d, 0x70, 0x18, 0x37, 0xb2, 0x09, 0xa9, 0xd2, 0x90, 0x4a, 0xb6, 0x0b, - 0x5c, 0x22, 0xd7, 0x31, 0x99, 0xb5, 0x24, 0x4e, 0x63, 0x67, 0xa2, 0x47, 0xde, 0xc1, 0x0e, 0xbc, - 0xa8, 0x1d, 0x77, 0x44, 0x1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bb, 0xba, 0x1a, 0x3e, 0x4b, 0x24, 0xcd, 0xae, 0x70, 0xe4, 0x0b, 0x4a, 0x54, 0xbf, 0xac, - 0xba, 0x6f, 0x66, 0x05, 0x5a, 0x86, 0xe7, 0x05, 0xea, 0xea, 0xab, 0x96, 0x40, 0xcb, 0xdb, 0xd1, - 0x6a, 0xbf, 0x12, 0xcf, 0x28, 0x81, 0xef, 0xc1, 0x66, 0xd9, 0xe5, 0x3c, 0x97, 0x2a, 0x7e, 0x55, - 0xc5, 0x3f, 0x9b, 0x15, 0xa8, 0x29, 0xcf, 0x0b, 0x04, 0x75, 0x6c, 0x43, 0xb4, 0x3c, 0x50, 0xed, - 0xce, 0x28, 0x71, 0x3f, 0xdc, 0x4c, 0x4c, 0xe3, 0x76, 0x62, 0x1a, 0xbf, 0x27, 0xa6, 0x71, 0x3d, - 0x35, 0x5b, 0xb7, 0x53, 0xb3, 0xf5, 0x63, 0x6a, 0xb6, 0x3e, 0x1f, 0x86, 0x4c, 0x5e, 0xe4, 0x43, - 0x9b, 0xf0, 0xd8, 0x39, 0x53, 0x83, 0xf8, 0xea, 0x14, 0x0f, 0x85, 0x53, 0x8d, 0xed, 0xd5, 0xc1, - 0x6b, 0xe7, 0x6b, 0x63, 0x78, 0xe5, 0x38, 0xa5, 0x62, 0xb8, 0xae, 0xfa, 0xe4, 0xf0, 0x4f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x56, 0xd4, 0xfb, 0xf2, 0xdd, 0x03, 0x00, 0x00, + // 610 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0x41, 0x6f, 0xd3, 0x30, + 0x1c, 0xc5, 0x1b, 0xd6, 0x8d, 0xd5, 0xd3, 0xd8, 0x96, 0x0d, 0x56, 0x15, 0x88, 0xab, 0x20, 0xa1, + 0x09, 0xb1, 0x44, 0xda, 0xe0, 0x00, 0x12, 0x07, 0xb2, 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 0x46, 0x78, 0x6f, + 0x49, 0x1d, 0xd6, 0xfd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x04, 0x20, 0xb2, 0x55, 0x04, + 0x00, 0x00, } func (m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -287,7 +290,7 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x48 + dAtA[i] = 0x40 } n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) if err1 != nil { @@ -296,57 +299,50 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintIcqoracle(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x3a { - size := m.Price.Size() + size := m.SpotPrice.Size() i -= size - if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.SpotPrice.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintIcqoracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x32 if len(m.OsmosisPoolId) > 0 { i -= len(m.OsmosisPoolId) copy(dAtA[i:], m.OsmosisPoolId) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisPoolId))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } if len(m.OsmosisQuoteDenom) > 0 { i -= len(m.OsmosisQuoteDenom) copy(dAtA[i:], m.OsmosisQuoteDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisQuoteDenom))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } if len(m.OsmosisBaseDenom) > 0 { i -= len(m.OsmosisBaseDenom) copy(dAtA[i:], m.OsmosisBaseDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisBaseDenom))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) copy(dAtA[i:], m.QuoteDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.QuoteDenom))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.BaseDenom) > 0 { i -= len(m.BaseDenom) copy(dAtA[i:], m.BaseDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.BaseDenom))) i-- - dAtA[i] = 0x12 - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.Denom))) - i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -372,8 +368,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.TimeoutSec != 0 { - i = encodeVarintIcqoracle(dAtA, i, uint64(m.TimeoutSec)) + if m.IcqTimeoutSec != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.IcqTimeoutSec)) + i-- + dAtA[i] = 0x28 + } + if m.PriceStaleTimeoutSec != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.PriceStaleTimeoutSec)) i-- dAtA[i] = 0x20 } @@ -416,10 +417,6 @@ func (m *TokenPrice) Size() (n int) { } var l int _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovIcqoracle(uint64(l)) - } l = len(m.BaseDenom) if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) @@ -440,7 +437,7 @@ func (m *TokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) } - l = m.Price.Size() + l = m.SpotPrice.Size() n += 1 + l + sovIcqoracle(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) n += 1 + l + sovIcqoracle(uint64(l)) @@ -467,8 +464,11 @@ func (m *Params) Size() (n int) { if m.UpdateIntervalSec != 0 { n += 1 + sovIcqoracle(uint64(m.UpdateIntervalSec)) } - if m.TimeoutSec != 0 { - n += 1 + sovIcqoracle(uint64(m.TimeoutSec)) + if m.PriceStaleTimeoutSec != 0 { + n += 1 + sovIcqoracle(uint64(m.PriceStaleTimeoutSec)) + } + if m.IcqTimeoutSec != 0 { + n += 1 + sovIcqoracle(uint64(m.IcqTimeoutSec)) } return n } @@ -509,38 +509,6 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIcqoracle - } - 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 ErrInvalidLengthIcqoracle - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIcqoracle - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) } @@ -572,7 +540,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.BaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", wireType) } @@ -604,7 +572,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisBaseDenom", wireType) } @@ -636,7 +604,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.OsmosisBaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisQuoteDenom", wireType) } @@ -668,7 +636,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } @@ -700,9 +668,9 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -730,11 +698,11 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.SpotPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 8: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) } @@ -767,7 +735,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", wireType) } @@ -922,9 +890,28 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeoutSec", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PriceStaleTimeoutSec", wireType) + } + m.PriceStaleTimeoutSec = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PriceStaleTimeoutSec |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IcqTimeoutSec", wireType) } - m.TimeoutSec = 0 + m.IcqTimeoutSec = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIcqoracle @@ -934,7 +921,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TimeoutSec |= uint64(b&0x7F) << shift + m.IcqTimeoutSec |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 32dc2c8490..45d60f2431 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -16,6 +16,6 @@ const ( KeyLastUpdateTime = "last_update_time" ) -func TokenPriceKey(denom, baseDenom, quoteDenom, poolId string) []byte { - return []byte(fmt.Sprintf("%s%s%s%s%s", KeyPricePrefix, denom, baseDenom, quoteDenom, poolId)) +func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { + return []byte(fmt.Sprintf("%s%s%s%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) } diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 22bd5379ee..5037ec8b17 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -2,6 +2,7 @@ package types import ( "errors" + "strconv" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -69,8 +70,8 @@ func (msg *MsgAddTokenPrice) ValidateBasic() error { if msg.QuoteDenom == "" { return errors.New("quote-denom must be specified") } - if msg.OsmosisPoolId == "" { - return errors.New("osmosis-pool-id must be specified") + if _, err := strconv.ParseUint(msg.OsmosisPoolId, 10, 64); err != nil { + return errors.New("osmosis-pool-id must be uint64") } if msg.OsmosisBaseDenom == "" { return errors.New("osmosis-base-denom must be specified") @@ -126,8 +127,8 @@ func (msg *MsgRemoveTokenPrice) ValidateBasic() error { if msg.QuoteDenom == "" { return errors.New("quote-denom must be specified") } - if msg.OsmosisPoolId == "" { - return errors.New("osmosis-pool-id must be specified") + if _, err := strconv.ParseUint(msg.OsmosisPoolId, 10, 64); err != nil { + return errors.New("osmosis-pool-id must be uint64") } return nil diff --git a/x/interchainquery/keeper/queries.go b/x/interchainquery/keeper/queries.go index 47dfffc5bb..24f1930a82 100644 --- a/x/interchainquery/keeper/queries.go +++ b/x/interchainquery/keeper/queries.go @@ -180,5 +180,6 @@ func UnmarshalAmountFromBalanceQuery(cdc codec.BinaryCodec, queryResponseBz []by } func UnmarshalSpotPriceFromSpotPriceV2Query(cdc codec.BinaryCodec, queryResponseBz []byte) (price sdkmath.LegacyDec, err error) { + panic("TODO") return sdkmath.LegacyDec{}, nil } diff --git a/x/interchainquery/types/keys.go b/x/interchainquery/types/keys.go index 7da8303e94..e3ca5c9e4a 100644 --- a/x/interchainquery/types/keys.go +++ b/x/interchainquery/types/keys.go @@ -1,6 +1,9 @@ package types -import fmt "fmt" +import ( + fmt "fmt" + "strconv" +) const ( // ModuleName defines the module name @@ -35,6 +38,8 @@ const ( BANK_STORE_QUERY_WITH_PROOF = "store/bank/key" // The Osmosis twap store - key'd by the pool ID and denom's TWAP_STORE_QUERY_WITH_PROOF = "store/twap/key" + // The Osmosis concentrated liquidity store + CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF = "store/concentratedliquidity/key" ) var ( @@ -62,3 +67,17 @@ func FormatOsmosisMostRecentTWAPKey(poolId uint64, denom1, denom2 string) []byte poolIdBz := fmt.Sprintf("%0.20d", poolId) return []byte(fmt.Sprintf("%s%s%s%s%s%s", OsmosisMostRecentTWAPsPrefix, poolIdBz, OsmosisKeySeparator, denom1, OsmosisKeySeparator, denom2)) } + +// Source: https://github.com/osmosis-labs/osmosis/blob/v27.0.0/x/concentrated-liquidity/types/keys.go#L227-L235 +// Used by: https://github.com/osmosis-labs/osmosis/blob/v27.0.0/x/concentrated-liquidity/pool.go#L117-L130 +// Which is used by: https://github.com/osmosis-labs/osmosis/blob/v27.0.0/x/concentrated-liquidity/pool.go#L179-L209 +// +// Pool Prefix Keys +// keyPool is used to map a pool id to a pool struct +func FormatOsmosisKeyPool(poolId uint64) []byte { + // Start with PoolPrefix initialized + result := []byte{0x03} + // Directly append the string representation of poolId as bytes + result = strconv.AppendUint(result, poolId, 10) + return result +} From cca478f0e78580ec0eab29aef157c7c83f26147b Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 11 Dec 2024 21:02:37 +0200 Subject: [PATCH 008/115] icqoracle: implement parsing of spot price from osmosis cl pools - fork only necessary osmomath files - fork cl pool types and price calc func --- x/icqoracle/deps/osmomath/decimal.go | 1282 +++++++++++++++++ x/icqoracle/deps/osmomath/exp2.go | 102 ++ x/icqoracle/deps/osmomath/int.go | 441 ++++++ x/icqoracle/deps/osmomath/sdk_math_alias.go | 56 + .../osmosis_concentrated_liquidity_pool.go | 36 + .../osmosis_concentrated_liquidity_pool.pb.go | 842 +++++++++++ x/icqoracle/keeper/abci.go | 2 +- x/icqoracle/keeper/icq.go | 38 +- x/interchainquery/keeper/queries.go | 5 - 9 files changed, 2787 insertions(+), 17 deletions(-) create mode 100644 x/icqoracle/deps/osmomath/decimal.go create mode 100644 x/icqoracle/deps/osmomath/exp2.go create mode 100644 x/icqoracle/deps/osmomath/int.go create mode 100644 x/icqoracle/deps/osmomath/sdk_math_alias.go create mode 100644 x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go create mode 100644 x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.pb.go diff --git a/x/icqoracle/deps/osmomath/decimal.go b/x/icqoracle/deps/osmomath/decimal.go new file mode 100644 index 0000000000..d84623b7d4 --- /dev/null +++ b/x/icqoracle/deps/osmomath/decimal.go @@ -0,0 +1,1282 @@ +// Forked from https://github.com/osmosis-labs/osmosis/blob/v27.0.0/osmomath/decimal.go under the Apache v2.0 License +package osmomath + +import ( + "encoding/json" + "errors" + "fmt" + "math/big" + "strconv" + "strings" + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NOTE: never use new(BigDec) or else we will panic unmarshalling into the +// nil embedded big.Int +type BigDec struct { + i *big.Int +} + +const ( + // number of decimal places + BigDecPrecision = 36 + + // bytes required to represent the above precision + // Ceiling[Log2[10**Precision - 1]] + BigDecimalPrecisionBits = 120 + + maxDecBitLen = maxBitLen + BigDecimalPrecisionBits + + // max number of iterations in ApproxRoot function + maxApproxRootIterations = 100 + + // max number of iterations in Log2 function + maxLog2Iterations = 300 +) + +var ( + defaultBigDecPrecisionReuse = new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision), nil) + precisionReuseSDKDec = new(big.Int).Exp(big.NewInt(10), big.NewInt(DecPrecision), nil) + + bigDecDecPrecision = new(big.Int).Mul(defaultBigDecPrecisionReuse, precisionReuseSDKDec) + squaredPrecisionReuse = new(big.Int).Mul(defaultBigDecPrecisionReuse, defaultBigDecPrecisionReuse) + bigDecDecPrecisionFactorDiff = new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision-DecPrecision), nil) + + tenTimesPrecision = new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision+1), nil) + fivePrecision = new(big.Int).Quo(defaultBigDecPrecisionReuse, big.NewInt(2)) + fivePrecisionSDKDec = new(big.Int).Quo(precisionReuseSDKDec, big.NewInt(2)) + + precisionMultipliers []*big.Int + zeroInt = big.NewInt(0) + oneInt = big.NewInt(1) + fiveInt = big.NewInt(5) + tenInt = big.NewInt(10) + + // log_2(e) + // From: https://www.wolframalpha.com/input?i=log_2%28e%29+with+37+digits + logOfEbase2 = MustNewBigDecFromStr("1.442695040888963407359924681001892137") + + // log_2(1.0001) + // From: https://www.wolframalpha.com/input?i=log_2%281.0001%29+to+33+digits + tickLogOf2 = MustNewBigDecFromStr("0.000144262291094554178391070900057480") + // initialized in init() since requires + // precision to be defined. + twoBigDec BigDec = MustNewBigDecFromStr("2") + + // precisionFactors are used to adjust the scale of big.Int values to match the desired precision + precisionFactors = make(map[uint64]*big.Int) + + zeroBigDec BigDec = ZeroBigDec() + oneBigDec BigDec = OneBigDec() + oneHalfBigDec BigDec = oneBigDec.Quo(twoBigDec) + negOneBigDec BigDec = oneBigDec.Neg() +) + +// Decimal errors +var ( + ErrEmptyDecimalStr = errors.New("decimal string cannot be empty") + ErrInvalidDecimalLength = errors.New("invalid decimal length") + ErrInvalidDecimalStr = errors.New("invalid decimal string") +) + +// Set precision multipliers +func init() { + precisionMultipliers = make([]*big.Int, BigDecPrecision+1) + for i := 0; i <= BigDecPrecision; i++ { + precisionMultipliers[i] = calcPrecisionMultiplier(int64(i)) + } + + for precision := uint64(0); precision <= BigDecPrecision; precision++ { + precisionFactor := new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision-int64(precision)), nil) + precisionFactors[precision] = precisionFactor + } +} + +func precisionInt() *big.Int { + return new(big.Int).Set(defaultBigDecPrecisionReuse) +} + +func ZeroBigDec() BigDec { return BigDec{new(big.Int).Set(zeroInt)} } +func OneBigDec() BigDec { return BigDec{precisionInt()} } +func SmallestBigDec() BigDec { return BigDec{new(big.Int).Set(oneInt)} } + +// calculate the precision multiplier +func calcPrecisionMultiplier(prec int64) *big.Int { + if prec > BigDecPrecision { + panic(fmt.Sprintf("too much precision, maximum %v, provided %v", BigDecPrecision, prec)) + } + zerosToAdd := BigDecPrecision - prec + multiplier := new(big.Int).Exp(tenInt, big.NewInt(zerosToAdd), nil) + return multiplier +} + +// get the precision multiplier, do not mutate result +func precisionMultiplier(prec int64) *big.Int { + if prec > BigDecPrecision { + panic(fmt.Sprintf("too much precision, maximum %v, provided %v", BigDecPrecision, prec)) + } + return precisionMultipliers[prec] +} + +// create a new NewBigDec from integer assuming whole number +func NewBigDec(i int64) BigDec { + return NewBigDecWithPrec(i, 0) +} + +// create a new BigDec from integer with decimal place at prec +// CONTRACT: prec <= BigDecPrecision +func NewBigDecWithPrec(i, prec int64) BigDec { + bi := big.NewInt(i) + return BigDec{ + bi.Mul(bi, precisionMultiplier(prec)), + } +} + +// create a new BigDec from big integer assuming whole numbers +// CONTRACT: prec <= BigDecPrecision +func NewBigDecFromBigInt(i *big.Int) BigDec { + return NewBigDecFromBigIntWithPrec(i, 0) +} + +func NewBigDecFromBigIntMut(i *big.Int) BigDec { + return NewBigDecFromBigIntMutWithPrec(i, 0) +} + +// create a new BigDec from big integer assuming whole numbers +// CONTRACT: prec <= BigDecPrecision +func NewBigDecFromBigIntWithPrec(i *big.Int, prec int64) BigDec { + return BigDec{ + new(big.Int).Mul(i, precisionMultiplier(prec)), + } +} + +// returns a BigDec, built using a mutated copy of the passed in bigint. +// CONTRACT: prec <= BigDecPrecision +func NewBigDecFromBigIntMutWithPrec(i *big.Int, prec int64) BigDec { + return BigDec{ + i.Mul(i, precisionMultiplier(prec)), + } +} + +// create a new BigDec from big integer assuming whole numbers +// CONTRACT: prec <= BigDecPrecision +func NewBigDecFromInt(i BigInt) BigDec { + return NewBigDecFromIntWithPrec(i, 0) +} + +// create a new BigDec from big integer with decimal place at prec +// CONTRACT: prec <= BigDecPrecision +func NewBigDecFromIntWithPrec(i BigInt, prec int64) BigDec { + return BigDec{ + new(big.Int).Mul(i.BigInt(), precisionMultiplier(prec)), + } +} + +func NewBigDecFromDecMulDec(a, b Dec) BigDec { + newBi := new(big.Int).Mul(a.BigIntMut(), b.BigIntMut()) + return BigDec{newBi} +} + +// create a decimal from an input decimal string. +// valid must come in the form: +// +// (-) whole integers (.) decimal integers +// +// examples of acceptable input include: +// +// -123.456 +// 456.7890 +// 345 +// -456789 +// +// NOTE - An error will return if more decimal places +// are provided in the string than the constant Precision. +// +// CONTRACT - This function does not mutate the input str. +func NewBigDecFromStr(str string) (BigDec, error) { + if len(str) == 0 { + return BigDec{}, ErrEmptyDecimalStr + } + + // first extract any negative symbol + neg := false + if str[0] == '-' { + neg = true + str = str[1:] + } + + if len(str) == 0 { + return BigDec{}, ErrEmptyDecimalStr + } + + strs := strings.Split(str, ".") + lenDecs := 0 + combinedStr := strs[0] + + if len(strs) == 2 { // has a decimal place + lenDecs = len(strs[1]) + if lenDecs == 0 || len(combinedStr) == 0 { + return BigDec{}, ErrInvalidDecimalLength + } + combinedStr += strs[1] + } else if len(strs) > 2 { + return BigDec{}, ErrInvalidDecimalStr + } + + if lenDecs > BigDecPrecision { + return BigDec{}, fmt.Errorf("invalid precision; max: %d, got: %d", BigDecPrecision, lenDecs) + } + + // add some extra zero's to correct to the Precision factor + zerosToAdd := BigDecPrecision - lenDecs + zeros := fmt.Sprintf(`%0`+strconv.Itoa(zerosToAdd)+`s`, "") + combinedStr += zeros + + combined, ok := new(big.Int).SetString(combinedStr, 10) // base 10 + if !ok { + return BigDec{}, fmt.Errorf("failed to set decimal string: %s", combinedStr) + } + if combined.BitLen() > maxBitLen { + return BigDec{}, fmt.Errorf("decimal out of range; bitLen: got %d, max %d", combined.BitLen(), maxBitLen) + } + if neg { + combined = new(big.Int).Neg(combined) + } + + return BigDec{combined}, nil +} + +// Decimal from string, panic on error +func MustNewBigDecFromStr(s string) BigDec { + dec, err := NewBigDecFromStr(s) + if err != nil { + panic(err) + } + return dec +} + +func (d BigDec) IsNil() bool { return d.i == nil } // is decimal nil +func (d BigDec) IsZero() bool { return (d.i).Sign() == 0 } // is equal to zero +func (d BigDec) IsNegative() bool { return (d.i).Sign() == -1 } // is negative +func (d BigDec) IsPositive() bool { return (d.i).Sign() == 1 } // is positive +func (d BigDec) Equal(d2 BigDec) bool { return (d.i).Cmp(d2.i) == 0 } // equal decimals +func (d BigDec) GT(d2 BigDec) bool { return (d.i).Cmp(d2.i) > 0 } // greater than +func (d BigDec) GTE(d2 BigDec) bool { return (d.i).Cmp(d2.i) >= 0 } // greater than or equal +func (d BigDec) LT(d2 BigDec) bool { return (d.i).Cmp(d2.i) < 0 } // less than +func (d BigDec) LTE(d2 BigDec) bool { return (d.i).Cmp(d2.i) <= 0 } // less than or equal +func (d BigDec) Neg() BigDec { return BigDec{new(big.Int).Neg(d.i)} } // reverse the decimal sign +// nolint: stylecheck +func (d BigDec) Abs() BigDec { return BigDec{new(big.Int).Abs(d.i)} } // absolute value +func (d BigDec) AbsMut() BigDec { d.i.Abs(d.i); return d } // absolute value + +// BigInt returns a copy of the underlying big.Int. +func (d BigDec) BigInt() *big.Int { + if d.IsNil() { + return nil + } + + cp := new(big.Int) + return cp.Set(d.i) +} + +// BigIntMut returns the pointer of the underlying big.Int. +func (d BigDec) BigIntMut() *big.Int { + if d.IsNil() { + return nil + } + + return d.i +} + +// addition +func (d BigDec) Add(d2 BigDec) BigDec { + copy := d.Clone() + copy.AddMut(d2) + return copy +} + +// mutative addition +func (d BigDec) AddMut(d2 BigDec) BigDec { + d.i.Add(d.i, d2.i) + + assertMaxBitLen(d.i) + + return d +} + +// subtraction +func (d BigDec) Sub(d2 BigDec) BigDec { + copy := d.Clone() + copy.SubMut(d2) + return copy +} + +func (d BigDec) SubMut(d2 BigDec) BigDec { + res := d.i.Sub(d.i, d2.i) + assertMaxBitLen(res) + return BigDec{res} +} + +func (d BigDec) NegMut() BigDec { + d.i.Neg(d.i) + return d +} // reverse the decimal sign + +// Clone performs a deep copy of the receiver +// and returns the new result. +func (d BigDec) Clone() BigDec { + copy := BigDec{new(big.Int)} + copy.i.Set(d.i) + return copy +} + +// Mut performs non-mutative multiplication. +// The receiver is not modifier but the result is. +func (d BigDec) Mul(d2 BigDec) BigDec { + copy := d.Clone() + copy.MulMut(d2) + return copy +} + +// Mut performs non-mutative multiplication. +// The receiver is not modifier but the result is. +func (d BigDec) MulMut(d2 BigDec) BigDec { + d.i.Mul(d.i, d2.i) + d.i = chopPrecisionAndRound(d.i) + + assertMaxBitLen(d.i) + return BigDec{d.i} +} + +func (d BigDec) MulDec(d2 Dec) BigDec { + copy := d.Clone() + copy.MulDecMut(d2) + return copy +} + +func (d BigDec) MulDecMut(d2 Dec) BigDec { + d.i.Mul(d.i, d2.BigIntMut()) + d.i = chopPrecisionAndRoundSdkDec(d.i) + + assertMaxBitLen(d.i) + return BigDec{d.i} +} + +// multiplication truncate +func (d BigDec) MulTruncate(d2 BigDec) BigDec { + mul := new(big.Int).Mul(d.i, d2.i) + chopped := chopPrecisionAndTruncateMut(mul, defaultBigDecPrecisionReuse) + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +func (d BigDec) MulTruncateDec(d2 Dec) BigDec { + mul := new(big.Int).Mul(d.i, d2.BigIntMut()) + chopped := chopPrecisionAndTruncateMut(mul, precisionReuseSDKDec) + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +// multiplication round up +func (d BigDec) MulRoundUp(d2 BigDec) BigDec { + mul := new(big.Int).Mul(d.i, d2.i) + chopped := chopPrecisionAndRoundUpMut(mul, defaultBigDecPrecisionReuse) + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +// multiplication round up by Dec +func (d BigDec) MulRoundUpDec(d2 Dec) BigDec { + mul := new(big.Int).Mul(d.i, d2.BigIntMut()) + chopped := chopPrecisionAndRoundUpMut(mul, precisionReuseSDKDec) + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +// multiplication +func (d BigDec) MulInt(i BigInt) BigDec { + mul := new(big.Int).Mul(d.i, i.i) + assertMaxBitLen(mul) + return BigDec{mul} +} + +// MulInt64 - multiplication with int64 +func (d BigDec) MulInt64(i int64) BigDec { + bi := big.NewInt(i) + mul := bi.Mul(d.i, bi) + assertMaxBitLen(mul) + return BigDec{mul} +} + +// quotient +func (d BigDec) Quo(d2 BigDec) BigDec { + copy := d.Clone() + copy.QuoMut(d2) + return copy +} + +// mutative quotient +func (d BigDec) QuoMut(d2 BigDec) BigDec { + // multiply precision twice + // TODO: Use lower overhead thing here + d.i.Mul(d.i, squaredPrecisionReuse) + + d.i.Quo(d.i, d2.i) + chopPrecisionAndRound(d.i) + + assertMaxBitLen(d.i) + return d +} + +func (d BigDec) QuoRaw(d2 int64) BigDec { + // multiply precision, so we can chop it later + // TODO: There is certainly more efficient ways to do this, come back later + mul := new(big.Int).Mul(d.i, defaultBigDecPrecisionReuse) + + quo := mul.Quo(mul, big.NewInt(d2)) + chopped := chopPrecisionAndRound(quo) + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +// quotient truncate +func (d BigDec) QuoTruncate(d2 BigDec) BigDec { + mul := new(big.Int).Mul(d.i, defaultBigDecPrecisionReuse) + quo := mul.Quo(mul, d2.i) + assertMaxBitLen(quo) + return BigDec{quo} +} + +// quotient truncate (mutative) +func (d BigDec) QuoTruncateMut(d2 BigDec) BigDec { + // multiply bigDec precision + d.i.Mul(d.i, defaultBigDecPrecisionReuse) + d.i.Quo(d.i, d2.i) + assertMaxBitLen(d.i) + return d +} + +// quotient truncate +func (d BigDec) QuoTruncateDec(d2 Dec) BigDec { + // multiply Dec Precision + mul := new(big.Int).Mul(d.i, precisionReuseSDKDec) + quo := mul.Quo(mul, d2.BigIntMut()) + assertMaxBitLen(quo) + return BigDec{quo} +} + +// quotient truncate (mutative) +func (d BigDec) QuoTruncateDecMut(d2 Dec) BigDec { + // multiply Dec Precision + d.i.Mul(d.i, precisionReuseSDKDec) + d.i.Quo(d.i, d2.BigIntMut()) + + assertMaxBitLen(d.i) + return d +} + +// quotient, round up +func (d BigDec) QuoRoundUp(d2 BigDec) BigDec { + mul := new(big.Int).Mul(d.i, defaultBigDecPrecisionReuse) + + chopped, rem := mul.QuoRem(mul, d2.i, new(big.Int)) + if rem.Sign() > 0 { + chopped.Add(chopped, oneInt) + } + + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +// quotient, round up +func (d BigDec) QuoByDecRoundUp(d2 Dec) BigDec { + mul := new(big.Int).Mul(d.i, precisionReuseSDKDec) + + chopped, rem := mul.QuoRem(mul, d2.BigIntMut(), new(big.Int)) + if rem.Sign() > 0 { + chopped.Add(chopped, oneInt) + } + + assertMaxBitLen(chopped) + return BigDec{chopped} +} + +// quotient, round up (mutative) +func (d BigDec) QuoRoundUpMut(d2 BigDec) BigDec { + d.i.Mul(d.i, defaultBigDecPrecisionReuse) + _, rem := d.i.QuoRem(d.i, d2.i, new(big.Int)) + + d.i = incBasedOnRem(rem, d.i) + assertMaxBitLen(d.i) + return BigDec{d.i} +} + +// quotient, round up to next integer (mutative) +func (d BigDec) QuoRoundUpNextIntMut(d2 BigDec) BigDec { + _, rem := d.i.QuoRem(d.i, d2.i, new(big.Int)) + + d.i = incBasedOnRem(rem, d.i) + d.i.Mul(d.i, defaultBigDecPrecisionReuse) + assertMaxBitLen(d.i) + return BigDec{d.i} +} + +// quotient +func (d BigDec) QuoInt(i BigInt) BigDec { + mul := new(big.Int).Quo(d.i, i.i) + return BigDec{mul} +} + +// QuoInt64 - quotient with int64 +func (d BigDec) QuoInt64(i int64) BigDec { + mul := new(big.Int).Quo(d.i, big.NewInt(i)) + return BigDec{mul} +} + +// ApproxRoot returns an approximate estimation of a Dec's positive real nth root +// using Newton's method (where n is positive). The algorithm starts with some guess and +// computes the sequence of improved guesses until an answer converges to an +// approximate answer. It returns `|d|.ApproxRoot() * -1` if input is negative. +// A maximum number of 100 iterations is used a backup boundary condition for +// cases where the answer never converges enough to satisfy the main condition. +func (d BigDec) ApproxRoot(root uint64) (guess BigDec, err error) { + defer func() { + if r := recover(); r != nil { + var ok bool + err, ok = r.(error) + if !ok { + err = errors.New("out of bounds") + } + } + }() + + if d.IsNegative() { + absRoot, err := d.MulInt64(-1).ApproxRoot(root) + return absRoot.MulInt64(-1), err + } + + if root == 1 || d.IsZero() || d.Equal(oneBigDec) { + return d, nil + } + + if root == 0 { + return OneBigDec(), nil + } + + rootInt := NewBigIntFromUint64(root) + guess, delta := OneBigDec(), OneBigDec() + + for iter := 0; delta.Abs().GT(SmallestBigDec()) && iter < maxApproxRootIterations; iter++ { + prev := guess.PowerInteger(root - 1) + if prev.IsZero() { + prev = SmallestBigDec() + } + delta = d.Quo(prev) + delta.SubMut(guess) + delta = delta.QuoInt(rootInt) + + guess = guess.Add(delta) + } + + return guess, nil +} + +func assertMaxBitLen(i *big.Int) { + if i.BitLen() > maxDecBitLen { + panic("Int overflow") + } +} + +// ApproxSqrt is a wrapper around ApproxRoot for the common special case +// of finding the square root of a number. It returns -(sqrt(abs(d)) if input is negative. +// TODO: Optimize this to be faster just using native big int sqrt. +func (d BigDec) ApproxSqrt() (BigDec, error) { + return d.ApproxRoot(2) +} + +// is integer, e.g. decimals are zero +func (d BigDec) IsInteger() bool { + return new(big.Int).Rem(d.i, defaultBigDecPrecisionReuse).Sign() == 0 +} + +// format decimal state +func (d BigDec) Format(s fmt.State, verb rune) { + _, err := s.Write([]byte(d.String())) + if err != nil { + panic(err) + } +} + +// String returns a BigDec as a string. +func (d BigDec) String() string { + if d.i == nil { + return d.i.String() + } + + isNeg := d.IsNegative() + + if isNeg { + d = d.Neg() + } + + bzInt, err := d.i.MarshalText() + if err != nil { + return "" + } + inputSize := len(bzInt) + + var bzStr []byte + + // TODO: Remove trailing zeros + // case 1, purely decimal + if inputSize <= BigDecPrecision { + bzStr = make([]byte, BigDecPrecision+2) + + // 0. prefix + bzStr[0] = byte('0') + bzStr[1] = byte('.') + + // set relevant digits to 0 + for i := 0; i < BigDecPrecision-inputSize; i++ { + bzStr[i+2] = byte('0') + } + + // set final digits + copy(bzStr[2+(BigDecPrecision-inputSize):], bzInt) + } else { + // inputSize + 1 to account for the decimal point that is being added + bzStr = make([]byte, inputSize+1) + decPointPlace := inputSize - BigDecPrecision + + copy(bzStr, bzInt[:decPointPlace]) // pre-decimal digits + bzStr[decPointPlace] = byte('.') // decimal point + copy(bzStr[decPointPlace+1:], bzInt[decPointPlace:]) // post-decimal digits + } + + if isNeg { + return "-" + string(bzStr) + } + + return string(bzStr) +} + +// Float64 returns the float64 representation of a BigDec. +// Will return the error if the conversion failed. +func (d BigDec) Float64() (float64, error) { + return strconv.ParseFloat(d.String(), 64) +} + +// MustFloat64 returns the float64 representation of a BigDec. +// Would panic if the conversion failed. +func (d BigDec) MustFloat64() float64 { + if value, err := strconv.ParseFloat(d.String(), 64); err != nil { + panic(err) + } else { + return value + } +} + +// Dec returns the osmomath.Dec representation of a BigDec. +// Values in any additional decimal places are truncated. +func (d BigDec) Dec() Dec { + dec := math.LegacyNewDec(0) + decBi := dec.BigIntMut() + decBi.Quo(d.i, bigDecDecPrecisionFactorDiff) + return dec +} + +// DecWithPrecision converts BigDec to Dec with desired precision +// Example: +// BigDec: 1.010100000000153000000000000000000000 +// precision: 4 +// Output Dec: 1.010100000000000000 +// Panics if precision exceeds DecPrecision +func (d BigDec) DecWithPrecision(precision uint64) Dec { + var precisionFactor *big.Int + if precision > DecPrecision { + panic(fmt.Sprintf("maximum Dec precision is (%v), provided (%v)", DecPrecision, precision)) + } else { + precisionFactor = precisionFactors[precision] + } + + // Truncate any additional decimal values that exist due to BigDec's additional precision + // This relies on big.Int's Quo function doing floor division + intRepresentation := new(big.Int).Quo(d.BigIntMut(), precisionFactor) + + // convert int representation back to SDK Dec precision + truncatedDec := NewDecFromBigIntWithPrec(intRepresentation, int64(precision)) + + return truncatedDec +} + +// ChopPrecisionMut truncates all decimals after precision numbers after decimal point. Mutative +// CONTRACT: precision <= BigDecPrecision +// Panics if precision exceeds BigDecPrecision +func (d *BigDec) ChopPrecisionMut(precision uint64) BigDec { + if precision > BigDecPrecision { + panic(fmt.Sprintf("maximum BigDec precision is (%v), provided (%v)", DecPrecision, precision)) + } + + precisionFactor := precisionFactors[precision] + // big.Quo truncates numbers that would have been after decimal point + d.i.Quo(d.i, precisionFactor) + d.i.Mul(d.i, precisionFactor) + return BigDec{d.i} +} + +// ChopPrecision truncates all decimals after precision numbers after decimal point +// CONTRACT: precision <= BigDecPrecision +// Panics if precision exceeds BigDecPrecision +func (d *BigDec) ChopPrecision(precision uint64) BigDec { + copy := d.Clone() + return copy.ChopPrecisionMut(precision) +} + +// DecRoundUp returns the osmomath.Dec representation of a BigDec. +// Round up at precision end. +// Values in any additional decimal places are truncated. +func (d BigDec) DecRoundUp() Dec { + dec := math.LegacyZeroDec() + decBi := dec.BigIntMut() + decBi, rem := decBi.QuoRem(d.i, bigDecDecPrecisionFactorDiff, big.NewInt(0)) + incBasedOnRem(rem, decBi) + return dec +} + +// BigDecFromDec returns the BigDec representation of an Dec. +// Values in any additional decimal places are truncated. +func BigDecFromDec(d Dec) BigDec { + return NewBigDecFromBigIntMutWithPrec(d.BigInt(), DecPrecision) +} + +// BigDecFromDec returns the BigDec representation of an Dec. +// Values in any additional decimal places are truncated. +func BigDecFromDecMut(d Dec) BigDec { + return NewBigDecFromBigIntMutWithPrec(d.BigIntMut(), DecPrecision) +} + +// BigDecFromSDKInt returns the BigDec representation of an sdkInt. +// Values in any additional decimal places are truncated. +func BigDecFromSDKInt(i Int) BigDec { + return NewBigDecFromBigIntWithPrec(i.BigIntMut(), 0) +} + +// BigDecFromDecSlice returns the []BigDec representation of an []Dec. +// Values in any additional decimal places are truncated. +func BigDecFromDecSlice(ds []Dec) []BigDec { + result := make([]BigDec, len(ds)) + for i, d := range ds { + result[i] = NewBigDecFromBigIntMutWithPrec(d.BigInt(), DecPrecision) + } + return result +} + +// BigDecFromDecSlice returns the []BigDec representation of an []Dec. +// Values in any additional decimal places are truncated. +func BigDecFromDecCoinSlice(ds []sdk.DecCoin) []BigDec { + result := make([]BigDec, len(ds)) + for i, d := range ds { + result[i] = NewBigDecFromBigIntMutWithPrec(d.Amount.BigInt(), DecPrecision) + } + return result +} + +// ____ +// __| |__ "chop 'em +// ` \ round!" +// ___|| ~ _ -bankers +// | | __ +// | | | __|__|__ +// |_____: / | $$$ | +// |________| + +// Remove a Precision amount of rightmost digits and perform bankers rounding +// on the remainder (gaussian rounding) on the digits which have been removed. +// +// Mutates the input. Use the non-mutative version if that is undesired +func chopPrecisionAndRound(d *big.Int) *big.Int { + // remove the negative and add it back when returning + if d.Sign() == -1 { + // make d positive, compute chopped value, and then un-mutate d + d = d.Neg(d) + d = chopPrecisionAndRound(d) + d = d.Neg(d) + return d + } + + // get the truncated quotient and remainder + quo, rem := d, big.NewInt(0) + quo, rem = quo.QuoRem(d, defaultBigDecPrecisionReuse, rem) + + if rem.Sign() == 0 { // remainder is zero + return quo + } + + switch rem.Cmp(fivePrecision) { + case -1: + return quo + case 1: + return quo.Add(quo, oneInt) + default: // bankers rounding must take place + // always round to an even number + if quo.Bit(0) == 0 { + return quo + } + return quo.Add(quo, oneInt) + } +} + +// TODO: Abstract code +func chopPrecisionAndRoundSdkDec(d *big.Int) *big.Int { + // remove the negative and add it back when returning + if d.Sign() == -1 { + // make d positive, compute chopped value, and then un-mutate d + d = d.Neg(d) + d = chopPrecisionAndRoundSdkDec(d) + d = d.Neg(d) + return d + } + + // get the truncated quotient and remainder + quo, rem := d, big.NewInt(0) + quo, rem = quo.QuoRem(d, precisionReuseSDKDec, rem) + + if rem.Sign() == 0 { // remainder is zero + return quo + } + + switch rem.Cmp(fivePrecisionSDKDec) { + case -1: + return quo + case 1: + return quo.Add(quo, oneInt) + default: // bankers rounding must take place + // always round to an even number + if quo.Bit(0) == 0 { + return quo + } + return quo.Add(quo, oneInt) + } +} + +// chopPrecisionAndRoundUpDec removes DecPrecision amount of rightmost digits and rounds up. +// Non-mutative. +func chopPrecisionAndRoundUpDec(d *big.Int) *big.Int { + copy := new(big.Int).Set(d) + return chopPrecisionAndRoundUpMut(copy, precisionReuseSDKDec) +} + +func incBasedOnRem(rem *big.Int, d *big.Int) *big.Int { + if rem.Sign() == 0 { + return d + } + return d.Add(d, oneInt) +} + +// chopPrecisionAndRoundUp removes a Precision amount of rightmost digits and rounds up. +// Mutates input d. +// Mutations occur: +// - By calling chopPrecisionAndTruncateMut. +// - Using input d directly in QuoRem. +func chopPrecisionAndRoundUpMut(d *big.Int, precisionReuse *big.Int) *big.Int { + // remove the negative and add it back when returning + if d.Sign() == -1 { + // make d positive, compute chopped value, and then un-mutate d + d = d.Neg(d) + // truncate since d is negative... + d = chopPrecisionAndTruncateMut(d, precisionReuse) + d = d.Neg(d) + return d + } + + // get the truncated quotient and remainder + _, rem := d.QuoRem(d, precisionReuse, big.NewInt(0)) + return incBasedOnRem(rem, d) +} + +func chopPrecisionAndRoundNonMutative(d *big.Int) *big.Int { + tmp := new(big.Int).Set(d) + return chopPrecisionAndRound(tmp) +} + +// RoundInt64 rounds the decimal using bankers rounding +func (d BigDec) RoundInt64() int64 { + chopped := chopPrecisionAndRoundNonMutative(d.i) + if !chopped.IsInt64() { + panic("Int64() out of bound") + } + return chopped.Int64() +} + +// RoundInt round the decimal using bankers rounding +func (d BigDec) RoundInt() BigInt { + return NewBigIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) +} + +// chopPrecisionAndTruncate is similar to chopPrecisionAndRound, +// but always rounds down. It does not mutate the input. +func chopPrecisionAndTruncate(d *big.Int, precisionReuse *big.Int) *big.Int { + return new(big.Int).Quo(d, precisionReuse) +} + +// chopPrecisionAndTruncate is similar to chopPrecisionAndRound, +// but always rounds down. It mutates the input. +func chopPrecisionAndTruncateMut(d, precisionReuse *big.Int) *big.Int { + return d.Quo(d, precisionReuse) +} + +// TruncateInt64 truncates the decimals from the number and returns an int64 +func (d BigDec) TruncateInt64() int64 { + chopped := chopPrecisionAndTruncate(d.i, defaultBigDecPrecisionReuse) + if !chopped.IsInt64() { + panic("Int64() out of bound") + } + return chopped.Int64() +} + +// TruncateInt truncates the decimals from the number and returns an Int +func (d BigDec) TruncateInt() BigInt { + return NewBigIntFromBigInt(chopPrecisionAndTruncate(d.i, defaultBigDecPrecisionReuse)) +} + +// TruncateDec truncates the decimals from the number and returns a Dec +func (d BigDec) TruncateDec() BigDec { + return NewBigDecFromBigInt(chopPrecisionAndTruncate(d.i, defaultBigDecPrecisionReuse)) +} + +// Ceil returns the smallest integer value (as a decimal) that is greater than +// or equal to the given decimal. +func (d BigDec) Ceil() BigDec { + tmp := new(big.Int).Set(d.i) + return BigDec{i: tmp}.CeilMut() +} + +func (d BigDec) CeilMut() BigDec { + quo, rem := d.i, big.NewInt(0) + quo, rem = quo.QuoRem(quo, defaultBigDecPrecisionReuse, rem) + + // no need to round with a zero remainder regardless of sign + if rem.Sign() <= 0 { + return NewBigDecFromBigIntMut(quo) + } + + return NewBigDecFromBigIntMut(quo.Add(quo, oneInt)) +} + +// reuse nil values +var nilJSON []byte + +func init() { + empty := new(big.Int) + bz, _ := empty.MarshalText() + nilJSON, _ = json.Marshal(string(bz)) +} + +// MarshalJSON marshals the decimal +func (d BigDec) MarshalJSON() ([]byte, error) { + if d.i == nil { + return nilJSON, nil + } + return json.Marshal(d.String()) +} + +// UnmarshalJSON defines custom decoding scheme +func (d *BigDec) UnmarshalJSON(bz []byte) error { + if d.i == nil { + d.i = new(big.Int) + } + + var text string + err := json.Unmarshal(bz, &text) + if err != nil { + return err + } + + // TODO: Reuse dec allocation + newDec, err := NewBigDecFromStr(text) + if err != nil { + return err + } + + d.i = newDec.i + return nil +} + +// MarshalYAML returns the YAML representation. +func (d BigDec) MarshalYAML() (interface{}, error) { + return d.String(), nil +} + +// Marshal implements the gogo proto custom type interface. +func (d BigDec) Marshal() ([]byte, error) { + if d.i == nil { + d.i = new(big.Int) + } + return d.i.MarshalText() +} + +// MarshalTo implements the gogo proto custom type interface. +func (d *BigDec) MarshalTo(data []byte) (n int, err error) { + if d.i == nil { + d.i = new(big.Int) + } + + if d.i.Sign() == 0 { + copy(data, []byte{0x30}) + return 1, nil + } + + bz, err := d.Marshal() + if err != nil { + return 0, err + } + + copy(data, bz) + return len(bz), nil +} + +// Unmarshal implements the gogo proto custom type interface. +func (d *BigDec) Unmarshal(data []byte) error { + if len(data) == 0 { + d = nil + return nil + } + + if d.i == nil { + d.i = new(big.Int) + } + + if err := d.i.UnmarshalText(data); err != nil { + return err + } + + if d.i.BitLen() > maxBitLen { + return fmt.Errorf("decimal out of range; got: %d, max: %d", d.i.BitLen(), maxBitLen) + } + + return nil +} + +// Size implements the gogo proto custom type interface. +func (d *BigDec) Size() int { + bz, _ := d.Marshal() + return len(bz) +} + +// Override Amino binary serialization by proxying to protobuf. +func (d BigDec) MarshalAmino() ([]byte, error) { return d.Marshal() } +func (d *BigDec) UnmarshalAmino(bz []byte) error { return d.Unmarshal(bz) } + +// helpers + +// DecsEqual tests if two decimal arrays are equal +func DecsEqual(d1s, d2s []BigDec) bool { + if len(d1s) != len(d2s) { + return false + } + + for i, d1 := range d1s { + if !d1.Equal(d2s[i]) { + return false + } + } + return true +} + +// MinBigDec gets minimum decimal between two +func MinBigDec(d1, d2 BigDec) BigDec { + if d1.LT(d2) { + return d1 + } + return d2 +} + +// MaxBigDec gets maximum decimal between two +func MaxBigDec(d1, d2 BigDec) BigDec { + if d1.LT(d2) { + return d2 + } + return d1 +} + +// DecEq returns true if two given decimals are equal. +// Intended to be used with require/assert: require.True(t, DecEq(...)) +// +//nolint:thelper +func DecEq(t *testing.T, exp, got BigDec) (*testing.T, bool, string, string, string) { + return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() +} + +// DecApproxEq returns true if the differences between two given decimals are smaller than the tolerance range. +// Intended to be used with require/assert: require.True(t, DecEq(...)) +// +//nolint:thelper +func DecApproxEq(t *testing.T, d1 BigDec, d2 BigDec, tol BigDec) (*testing.T, bool, string, string, string) { + diff := d1.Sub(d2).Abs() + return t, diff.LTE(tol), "expected |d1 - d2| <:\t%v\ngot |d1 - d2| = \t\t%v", tol.String(), diff.String() +} + +// LogBase2 returns log_2 {x}. +// Rounds down by truncations during division and right shifting. +// Accurate up to 32 precision digits. +// Implementation is based on: +// https://stm32duinoforum.com/forum/dsp/BinaryLogarithm.pdf +func (x BigDec) LogBase2() BigDec { + // create a new decimal to avoid mutating + // the receiver's int buffer. + xCopy := BigDec{} + xCopy.i = new(big.Int).Set(x.i) + if xCopy.LTE(zeroBigDec) { + panic(fmt.Sprintf("log is not defined at <= 0, given (%s)", xCopy)) + } + + // Normalize x to be 1 <= x < 2. + + // y is the exponent that results in a whole multiple of 2. + y := ZeroBigDec() + + // repeat until: x >= 1. + for xCopy.LT(oneBigDec) { + xCopy.i.Lsh(xCopy.i, 1) + y.AddMut(negOneBigDec) + } + + // repeat until: x < 2. + for xCopy.GTE(twoBigDec) { + xCopy.i.Rsh(xCopy.i, 1) + y.AddMut(oneBigDec) + } + + b := oneHalfBigDec.Clone() + + // N.B. At this point x is a positive real number representing + // mantissa of the log. We estimate it using the following + // algorithm: + // https://stm32duinoforum.com/forum/dsp/BinaryLogarithm.pdf + // This has shown precision of 32 digits relative + // to Wolfram Alpha in tests. + for i := 0; i < maxLog2Iterations; i++ { + xCopy.MulMut(xCopy) + if xCopy.GTE(twoBigDec) { + xCopy.i.Rsh(xCopy.i, 1) + y.AddMut(b) + } + b.i.Rsh(b.i, 1) + } + + return y +} + +// Natural logarithm of x. +// Formula: ln(x) = log_2(x) / log_2(e) +func (x BigDec) Ln() BigDec { + log2x := x.LogBase2() + + y := log2x.Quo(logOfEbase2) + + return y +} + +// log_1.0001(x) "tick" base logarithm +// Formula: log_1.0001(b) = log_2(b) / log_2(1.0001) +func (x BigDec) TickLog() BigDec { + log2x := x.LogBase2() + + y := log2x.Quo(tickLogOf2) + + return y +} + +// log_a(x) custom base logarithm +// Formula: log_a(b) = log_2(b) / log_2(a) +func (x BigDec) CustomBaseLog(base BigDec) BigDec { + if base.LTE(ZeroBigDec()) || base.Equal(OneBigDec()) { + panic(fmt.Sprintf("log is not defined at base <= 0 or base == 1, base given (%s)", base)) + } + + log2x_argument := x.LogBase2() + log2x_base := base.LogBase2() + + y := log2x_argument.Quo(log2x_base) + + return y +} + +// PowerInteger takes a given decimal to an integer power +// and returns the result. Non-mutative. Uses square and multiply +// algorithm for performing the calculation. +func (d BigDec) PowerInteger(power uint64) BigDec { + clone := d.Clone() + return clone.PowerIntegerMut(power) +} + +// PowerIntegerMut takes a given decimal to an integer power +// and returns the result. Mutative. Uses square and multiply +// algorithm for performing the calculation. +func (d BigDec) PowerIntegerMut(power uint64) BigDec { + if power == 0 { + return OneBigDec() + } else if power == 1 { + return d + } else if power == 2 { + // save a oneBigDec allocation + return d.MulMut(d) + } + tmp := OneBigDec() + + for i := power; i > 1; { + if i%2 != 0 { + tmp = tmp.MulMut(d) + } + i /= 2 + d = d.MulMut(d) + } + + return d.MulMut(tmp) +} + +// Power returns a result of raising the given big dec to +// a positive decimal power. Panics if the power is negative. +// Panics if the base is negative. Does not mutate the receiver. +// The max supported exponent is defined by the global maxSupportedExponent. +// If a greater exponent is given, the function panics. +// The error is not bounded but expected to be around 10^-18, use with care. +// See the underlying Exp2, LogBase2 and Mul for the details of their bounds. +// WARNING: This function is broken for base < 1. The reason is that logarithm function is +// negative between zero and 1, and the Exp2(k) is undefined for negative k. +// As a result, this function panics if called for d < 1. +func (d BigDec) Power(power BigDec) BigDec { + if d.IsNegative() { + panic(fmt.Sprintf("negative base is not supported for Power(), base was (%s)", d)) + } + if power.IsNegative() { + panic(fmt.Sprintf("negative power is not supported for Power(), power was (%s)", power)) + } + if power.Abs().GT(maxSupportedExponent) { + panic(fmt.Sprintf("integer exponent %s is too large, max (%s)", power, maxSupportedExponent)) + } + // TODO: Potentially expensive?? + if power.IsInteger() { + return d.PowerInteger(power.TruncateInt().Uint64()) + } + if power.IsZero() { + return OneBigDec() + } + if d.IsZero() { + return ZeroBigDec() + } + if d.LT(oneBigDec) { + panic(fmt.Sprintf("Power() is not supported for base < 1, base was (%s)", d)) + } + if d.Equal(twoBigDec) { + return Exp2(power) + } + + // d^power = exp2(power * log_2{base}) + result := Exp2(d.LogBase2().Mul(power)) + + return result +} diff --git a/x/icqoracle/deps/osmomath/exp2.go b/x/icqoracle/deps/osmomath/exp2.go new file mode 100644 index 0000000000..d9b43313f2 --- /dev/null +++ b/x/icqoracle/deps/osmomath/exp2.go @@ -0,0 +1,102 @@ +// Forked from https://github.com/osmosis-labs/osmosis/blob/v27.0.0/osmomath/exp2.go under the Apache v2.0 License +package osmomath + +import "fmt" + +var ( + // Truncated at precision end. + // See scripts/approximations/main.py exponent_approximation_choice function for details. + numeratorCoefficients13Param = []BigDec{ + MustNewBigDecFromStr("1.000000000000000000000044212244679434"), + MustNewBigDecFromStr("0.352032455817400196452603772766844426"), + MustNewBigDecFromStr("0.056507868883666405413116800969512484"), + MustNewBigDecFromStr("0.005343900728213034434757419480319916"), + MustNewBigDecFromStr("0.000317708814342353603087543715930732"), + MustNewBigDecFromStr("0.000011429747507407623028722262874632"), + MustNewBigDecFromStr("0.000000198381965651614980168744540366"), + } + + // Rounded up at precision end. + // See scripts/approximations/main.py exponent_approximation_choice function for details. + denominatorCoefficients13Param = []BigDec{ + OneBigDec(), + MustNewBigDecFromStr("0.341114724742545112949699755780593311").Neg(), + MustNewBigDecFromStr("0.052724071627342653404436933178482287"), + MustNewBigDecFromStr("0.004760950735524957576233524801866342").Neg(), + MustNewBigDecFromStr("0.000267168475410566529819971616894193"), + MustNewBigDecFromStr("0.000008923715368802211181557353097439").Neg(), + MustNewBigDecFromStr("0.000000140277233177373698516010555916"), + } + + // maxSupportedExponent = 2^10. The value is chosen by benchmarking + // when the underlying internal functions overflow. + // If needed in the future, Exp2 can be reimplemented to allow for greater exponents. + maxSupportedExponent = MustNewBigDecFromStr("2").PowerInteger(9) +) + +// Exp2 takes 2 to the power of a given non-negative decimal exponent +// and returns the result. +// The computation is performed by using th following property: +// 2^decimal_exp = 2^{integer_exp + fractional_exp} = 2^integer_exp * 2^fractional_exp +// The max supported exponent is defined by the global maxSupportedExponent. +// If a greater exponent is given, the function panics. +// Panics if the exponent is negative. +// The answer is correct up to a factor of 10^-18. +// Meaning, result = result * k for k in [1 - 10^(-18), 1 + 10^(-18)] +// Note: our Python script plots show accuracy up to a factor of 10^22. +// However, in Go tests we only test up to 10^18. Therefore, this is the guarantee. +func Exp2(exponent BigDec) BigDec { + if exponent.IsNegative() { + panic(fmt.Sprintf("negative exponent %s is not supported", exponent)) + } + if exponent.Abs().GT(maxSupportedExponent) { + panic(fmt.Sprintf("integer exponent %s is too large, max (%s)", exponent, maxSupportedExponent)) + } + + integerExponent := exponent.TruncateDec() + + fractionalExponent := exponent.Sub(integerExponent) + fractionalResult := exp2ChebyshevRationalApprox(fractionalExponent) + + // Left bit shift is equivalent to multiplying by 2^integerExponent. + fractionalResult.i = fractionalResult.i.Lsh(fractionalResult.i, uint(integerExponent.TruncateInt().Uint64())) + + return fractionalResult +} + +// exp2ChebyshevRationalApprox takes 2 to the power of a given decimal exponent. +// The result is approximated by a 13 parameter Chebyshev rational approximation. +// f(x) = h(x) / p(x) (7, 7) terms. We set the first term of p(x) to 1. +// As a result, this ends up being 7 + 6 = 13 parameters. +// The numerator coefficients are truncated at precision end. The denominator +// coefficients are rounded up at precision end. +// See scripts/approximations/README.md for details of the scripts used +// to compute the coefficients. +// CONTRACT: exponent must be in the range [0, 1], panics if not. +// The answer is correct up to a factor of 10^-18. +// Meaning, result = result * k for k in [1 - 10^(-18), 1 + 10^(-18)] +// Note: our Python script plots show accuracy up to a factor of 10^22. +// However, in Go tests we only test up to 10^18. Therefore, this is the guarantee. +func exp2ChebyshevRationalApprox(x BigDec) BigDec { + if x.LT(ZeroBigDec()) || x.GT(OneBigDec()) { + panic(fmt.Sprintf("exponent must be in the range [0, 1], got %s", x)) + } + if x.IsZero() { + return OneBigDec() + } + if x.Equal(OneBigDec()) { + return twoBigDec + } + + h_x := numeratorCoefficients13Param[0].Clone() + p_x := denominatorCoefficients13Param[0].Clone() + x_exp_i := OneBigDec() + for i := 1; i < len(numeratorCoefficients13Param); i++ { + x_exp_i.MulMut(x) + + h_x.AddMut(numeratorCoefficients13Param[i].Mul(x_exp_i)) + p_x.AddMut(denominatorCoefficients13Param[i].Mul(x_exp_i)) + } + + return h_x.QuoMut(p_x) +} diff --git a/x/icqoracle/deps/osmomath/int.go b/x/icqoracle/deps/osmomath/int.go new file mode 100644 index 0000000000..93e0c6ab5c --- /dev/null +++ b/x/icqoracle/deps/osmomath/int.go @@ -0,0 +1,441 @@ +// Forked from https://github.com/osmosis-labs/osmosis/blob/v27.0.0/osmomath/int.go under the Apache v2.0 License +package osmomath + +import ( + "encoding" + "encoding/json" + "fmt" + "math/big" + "testing" +) + +const maxBitLen = 1024 + +func newIntegerFromString(s string) (*big.Int, bool) { + return new(big.Int).SetString(s, 0) +} + +func equal(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 0 } + +// Greater than +func gt(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 1 } + +// Greater than or equal to +func gte(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) >= 0 } + +// Less than +func lt(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == -1 } + +// Less than or equal to +func lte(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) <= 0 } + +func add(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Add(i, i2) } + +func sub(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Sub(i, i2) } + +func mul(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mul(i, i2) } + +func div(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Quo(i, i2) } + +func mod(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mod(i, i2) } + +func neg(i *big.Int) *big.Int { return new(big.Int).Neg(i) } + +func abs(i *big.Int) *big.Int { return new(big.Int).Abs(i) } + +func min(i *big.Int, i2 *big.Int) *big.Int { + if i.Cmp(i2) == 1 { + return new(big.Int).Set(i2) + } + + return new(big.Int).Set(i) +} + +func max(i *big.Int, i2 *big.Int) *big.Int { + if i.Cmp(i2) == -1 { + return new(big.Int).Set(i2) + } + + return new(big.Int).Set(i) +} + +func unmarshalText(i *big.Int, text string) error { + if err := i.UnmarshalText([]byte(text)); err != nil { + return err + } + + if i.BitLen() > maxBitLen { + return fmt.Errorf("integer out of range: %s", text) + } + + return nil +} + +// Int wraps big.Int with a 257 bit range bound +// Checks overflow, underflow and division by zero +// Exists in range from -(2^256 - 1) to 2^256 - 1 +type BigInt struct { + i *big.Int +} + +// BigInt converts Int to big.Int +func (i BigInt) BigInt() *big.Int { + if i.IsNil() { + return nil + } + return new(big.Int).Set(i.i) +} + +// IsNil returns true if Int is uninitialized +func (i BigInt) IsNil() bool { + return i.i == nil +} + +// NewBigInt constructs Int from int64 +func NewBigInt(n int64) BigInt { + return BigInt{big.NewInt(n)} +} + +// NewBigIntFromUint64 constructs an Int from a uint64. +func NewBigIntFromUint64(n uint64) BigInt { + b := big.NewInt(0) + b.SetUint64(n) + return BigInt{b} +} + +// NewBigIntFromBigInt constructs Int from big.Int. If the provided big.Int is nil, +// it returns an empty instance. This function panics if the bit length is > 256. +func NewBigIntFromBigInt(i *big.Int) BigInt { + if i == nil { + return BigInt{} + } + + if i.BitLen() > maxBitLen { + panic("NewIntFromBigInt() out of bound") + } + return BigInt{i} +} + +// NewBigIntFromString constructs Int from string +func NewBigIntFromString(s string) (res BigInt, ok bool) { + i, ok := newIntegerFromString(s) + if !ok { + return + } + // Check overflow + if i.BitLen() > maxBitLen { + ok = false + return + } + return BigInt{i}, true +} + +// NewBigIntWithDecimal constructs Int with decimal +// Result value is n*10^dec +func NewBigIntWithDecimal(n int64, dec int) BigInt { + if dec < 0 { + panic("NewIntWithDecimal() decimal is negative") + } + exp := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(dec)), nil) + i := new(big.Int) + i.Mul(big.NewInt(n), exp) + + // Check overflow + if i.BitLen() > maxBitLen { + panic("NewIntWithDecimal() out of bound") + } + return BigInt{i} +} + +// ZeroBigInt returns Int value with zero +func ZeroBigInt() BigInt { return BigInt{big.NewInt(0)} } + +// OneBigInt returns Int value with one +func OneBigInt() BigInt { return BigInt{big.NewInt(1)} } + +// ToDec converts Int to Dec +func (i BigInt) ToDec() BigDec { + return NewBigDecFromInt(i) +} + +// Int64 converts Int to int64 +// Panics if the value is out of range +func (i BigInt) Int64() int64 { + if !i.i.IsInt64() { + panic("Int64() out of bound") + } + return i.i.Int64() +} + +// IsInt64 returns true if Int64() not panics +func (i BigInt) IsInt64() bool { + return i.i.IsInt64() +} + +// Uint64 converts Int to uint64 +// Panics if the value is out of range +func (i BigInt) Uint64() uint64 { + if !i.i.IsUint64() { + panic("Uint64() out of bounds") + } + return i.i.Uint64() +} + +// IsUint64 returns true if Uint64() not panics +func (i BigInt) IsUint64() bool { + return i.i.IsUint64() +} + +// IsZero returns true if Int is zero +func (i BigInt) IsZero() bool { + return i.i.Sign() == 0 +} + +// IsNegative returns true if Int is negative +func (i BigInt) IsNegative() bool { + return i.i.Sign() == -1 +} + +// IsPositive returns true if Int is positive +func (i BigInt) IsPositive() bool { + return i.i.Sign() == 1 +} + +// Sign returns sign of Int +func (i BigInt) Sign() int { + return i.i.Sign() +} + +// Equal compares two Ints +func (i BigInt) Equal(i2 BigInt) bool { + return equal(i.i, i2.i) +} + +// GT returns true if first Int is greater than second +func (i BigInt) GT(i2 BigInt) bool { + return gt(i.i, i2.i) +} + +// GTE returns true if receiver Int is greater than or equal to the parameter +// Int. +func (i BigInt) GTE(i2 BigInt) bool { + return gte(i.i, i2.i) +} + +// LT returns true if first Int is lesser than second +func (i BigInt) LT(i2 BigInt) bool { + return lt(i.i, i2.i) +} + +// LTE returns true if first Int is less than or equal to second +func (i BigInt) LTE(i2 BigInt) bool { + return lte(i.i, i2.i) +} + +// Add adds Int from another +func (i BigInt) Add(i2 BigInt) (res BigInt) { + res = BigInt{add(i.i, i2.i)} + // Check overflow + if res.i.BitLen() > maxBitLen { + panic("Int overflow") + } + return +} + +// AddRaw adds int64 to Int +func (i BigInt) AddRaw(i2 int64) BigInt { + return i.Add(NewBigInt(i2)) +} + +// Sub subtracts Int from another +func (i BigInt) Sub(i2 BigInt) (res BigInt) { + res = BigInt{sub(i.i, i2.i)} + // Check overflow + if res.i.BitLen() > maxBitLen { + panic("Int overflow") + } + return +} + +// SubRaw subtracts int64 from Int +func (i BigInt) SubRaw(i2 int64) BigInt { + return i.Sub(NewBigInt(i2)) +} + +// Mul multiples two Ints +func (i BigInt) Mul(i2 BigInt) (res BigInt) { + // Check overflow + if i.i.BitLen()+i2.i.BitLen()-1 > maxBitLen { + panic("Int overflow") + } + res = BigInt{mul(i.i, i2.i)} + // Check overflow if sign of both are same + if res.i.BitLen() > maxBitLen { + panic("Int overflow") + } + return +} + +// MulRaw multiplies Int and int64 +func (i BigInt) MulRaw(i2 int64) BigInt { + return i.Mul(NewBigInt(i2)) +} + +// Quo divides Int with Int +func (i BigInt) Quo(i2 BigInt) (res BigInt) { + // Check division-by-zero + if i2.i.Sign() == 0 { + panic("Division by zero") + } + return BigInt{div(i.i, i2.i)} +} + +// QuoRaw divides Int with int64 +func (i BigInt) QuoRaw(i2 int64) BigInt { + return i.Quo(NewBigInt(i2)) +} + +// Mod returns remainder after dividing with Int +func (i BigInt) Mod(i2 BigInt) BigInt { + if i2.Sign() == 0 { + panic("division-by-zero") + } + return BigInt{mod(i.i, i2.i)} +} + +// ModRaw returns remainder after dividing with int64 +func (i BigInt) ModRaw(i2 int64) BigInt { + return i.Mod(NewBigInt(i2)) +} + +// Neg negates Int +func (i BigInt) Neg() (res BigInt) { + return BigInt{neg(i.i)} +} + +// Abs returns the absolute value of Int. +func (i BigInt) Abs() BigInt { + return BigInt{abs(i.i)} +} + +// return the minimum of the ints +func MinBigInt(i1, i2 BigInt) BigInt { + return BigInt{min(i1.BigInt(), i2.BigInt())} +} + +// MaxBigInt returns the maximum between two integers. +func MaxBigInt(i, i2 BigInt) BigInt { + return BigInt{max(i.BigInt(), i2.BigInt())} +} + +// Human readable string +func (i BigInt) String() string { + return i.i.String() +} + +// MarshalJSON defines custom encoding scheme +func (i BigInt) MarshalJSON() ([]byte, error) { + if i.i == nil { // Necessary since default Uint initialization has i.i as nil + i.i = new(big.Int) + } + return marshalJSON(i.i) +} + +// UnmarshalJSON defines custom decoding scheme +func (i *BigInt) UnmarshalJSON(bz []byte) error { + if i.i == nil { // Necessary since default Int initialization has i.i as nil + i.i = new(big.Int) + } + return unmarshalJSON(i.i, bz) +} + +// MarshalJSON for custom encoding scheme +// Must be encoded as a string for JSON precision +func marshalJSON(i encoding.TextMarshaler) ([]byte, error) { + text, err := i.MarshalText() + if err != nil { + return nil, err + } + + return json.Marshal(string(text)) +} + +// UnmarshalJSON for custom decoding scheme +// Must be encoded as a string for JSON precision +func unmarshalJSON(i *big.Int, bz []byte) error { + var text string + if err := json.Unmarshal(bz, &text); err != nil { + return err + } + + return unmarshalText(i, text) +} + +// MarshalYAML returns the YAML representation. +func (i BigInt) MarshalYAML() (interface{}, error) { + return i.String(), nil +} + +// Marshal implements the gogo proto custom type interface. +func (i BigInt) Marshal() ([]byte, error) { + if i.i == nil { + i.i = new(big.Int) + } + return i.i.MarshalText() +} + +// MarshalTo implements the gogo proto custom type interface. +func (i *BigInt) MarshalTo(data []byte) (n int, err error) { + if i.i == nil { + i.i = new(big.Int) + } + if i.i.BitLen() == 0 { // The value 0 + copy(data, []byte{0x30}) + return 1, nil + } + + bz, err := i.Marshal() + if err != nil { + return 0, err + } + + copy(data, bz) + return len(bz), nil +} + +// Unmarshal implements the gogo proto custom type interface. +func (i *BigInt) Unmarshal(data []byte) error { + if len(data) == 0 { + i = nil + return nil + } + + if i.i == nil { + i.i = new(big.Int) + } + + if err := i.i.UnmarshalText(data); err != nil { + return err + } + + if i.i.BitLen() > maxBitLen { + return fmt.Errorf("integer out of range; got: %d, max: %d", i.i.BitLen(), maxBitLen) + } + + return nil +} + +// Size implements the gogo proto custom type interface. +func (i *BigInt) Size() int { + bz, _ := i.Marshal() + return len(bz) +} + +// Override Amino binary serialization by proxying to protobuf. +func (i BigInt) MarshalAmino() ([]byte, error) { return i.Marshal() } +func (i *BigInt) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } + +// intended to be used with require/assert: require.True(IntEq(...)) +func BigIntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) { + return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() +} diff --git a/x/icqoracle/deps/osmomath/sdk_math_alias.go b/x/icqoracle/deps/osmomath/sdk_math_alias.go new file mode 100644 index 0000000000..accf9ec891 --- /dev/null +++ b/x/icqoracle/deps/osmomath/sdk_math_alias.go @@ -0,0 +1,56 @@ +// Forked from https://github.com/osmosis-labs/osmosis/blob/v27.0.0/osmomath/sdk_math_alias.go under the Apache v2.0 License +// This file creates type and function aliases the sdkmath.LegacyDec +// This is done for reducing verbosity and improving readability. +// +// For consistency, we also alias Int and Uint so that sdkmath does not have +// to be directly imported in files where both decimal and integer types are used. +package osmomath + +import ( + sdkmath "cosmossdk.io/math" +) + +type ( + Dec = sdkmath.LegacyDec + Int = sdkmath.Int + Uint = sdkmath.Uint +) + +const ( + DecPrecision = sdkmath.LegacyPrecision + DecimalPrecisionBits = sdkmath.LegacyDecimalPrecisionBits +) + +var ( + // Dec + NewDec = sdkmath.LegacyNewDec + NewDecWithPrec = sdkmath.LegacyNewDecWithPrec + NewDecFromBigInt = sdkmath.LegacyNewDecFromBigInt + NewDecFromBigIntWithPrec = sdkmath.LegacyNewDecFromBigIntWithPrec + NewDecFromInt = sdkmath.LegacyNewDecFromInt + NewDecFromIntWithPrec = sdkmath.LegacyNewDecFromIntWithPrec + NewDecFromStr = sdkmath.LegacyNewDecFromStr + MustNewDecFromStr = sdkmath.LegacyMustNewDecFromStr + ZeroDec = sdkmath.LegacyZeroDec + OneDec = sdkmath.LegacyOneDec + SmallestDec = sdkmath.LegacySmallestDec + + // Int + NewInt = sdkmath.NewInt + NewIntFromUint64 = sdkmath.NewIntFromUint64 + NewIntFromBigInt = sdkmath.NewIntFromBigInt + NewIntFromString = sdkmath.NewIntFromString + NewIntWithDecimal = sdkmath.NewIntWithDecimal + ZeroInt = sdkmath.ZeroInt + OneInt = sdkmath.OneInt + IntEq = sdkmath.IntEq + MinInt = sdkmath.MinInt + MaxInt = sdkmath.MaxInt + + // Uint + NewUint = sdkmath.NewUint + NewUintFromString = sdkmath.NewUintFromString + + MinDec = sdkmath.LegacyMinDec + MaxDec = sdkmath.LegacyMaxDec +) diff --git a/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go b/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go new file mode 100644 index 0000000000..a6a178466e --- /dev/null +++ b/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go @@ -0,0 +1,36 @@ +package types + +import ( + fmt "fmt" + + "cosmossdk.io/math" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/deps/osmomath" +) + +// SpotPrice returns the spot price of the pool. +// If base asset is the Token0 of the pool, we use the current sqrt price of the pool. +// If not, we calculate the inverse of the current sqrt price of the pool. +// +// Forked from https://github.com/osmosis-labs/osmosis/blob/v27.0.0/x/concentrated-liquidity/model/pool.go#L108-L129 under the Apache v2.0 License. +// Modified to return math.LegacyDec instead of osmomath.BigDec. +// Removed unused ctx param. +func (p OsmosisConcentratedLiquidityPool) SpotPrice(quoteAssetDenom string, baseAssetDenom string) (math.LegacyDec, error) { + // validate base asset is in pool + if baseAssetDenom != p.Token0 && baseAssetDenom != p.Token1 { + return math.LegacyDec{}, fmt.Errorf("base asset denom (%s) is not in pool with (%s, %s) pair", baseAssetDenom, p.Token0, p.Token1) + } + // validate quote asset is in pool + if quoteAssetDenom != p.Token0 && quoteAssetDenom != p.Token1 { + return math.LegacyDec{}, fmt.Errorf("quote asset denom (%s) is not in pool with (%s, %s) pair", quoteAssetDenom, p.Token0, p.Token1) + } + + priceSquared := p.CurrentSqrtPrice.PowerInteger(2) + // The reason why we convert the result to Dec and then back to BigDec is to temporarily + // maintain backwards compatibility with the original implementation. + // TODO: remove before https://github.com/osmosis-labs/osmosis/issues/5726 is complete + if baseAssetDenom == p.Token0 { + return priceSquared.Dec(), nil + } + return osmomath.OneBigDec().QuoMut(priceSquared).Dec(), nil +} diff --git a/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.pb.go b/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.pb.go new file mode 100644 index 0000000000..dc77cf7e26 --- /dev/null +++ b/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.pb.go @@ -0,0 +1,842 @@ +// Forked from https://github.com/osmosis-labs/osmosis/blob/3941926d1ace180a689951f66b01a0ecc0603d93/x/concentrated-liquidity/model/pool.pb.go under the Apache v2.0 License +// Changes made: +// 1. Pointed import path of osmomath to Stride's forked version +// 2. Implemented `func (m *Pool) String() string` (difference in gogoproto version between Osmosis and Stride) +// 3. Renamed Pool -> OsmosisConcentratedLiquidityPool + +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/concentratedliquidity/v1beta1/pool.proto + +// This is a legacy package that requires additional migration logic +// in order to use the correct package. Decision made to use legacy package path +// until clear steps for migration logic and the unknowns for state breaking are +// investigated for changing proto package. + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + "github.com/Stride-Labs/stride/v24/x/icqoracle/deps/osmomath" + _ "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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type OsmosisConcentratedLiquidityPool struct { + // pool's address holding all liquidity tokens. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + // address holding the incentives liquidity. + IncentivesAddress string `protobuf:"bytes,2,opt,name=incentives_address,json=incentivesAddress,proto3" json:"incentives_address,omitempty" yaml:"incentives_address"` + // address holding spread rewards from swaps. + SpreadRewardsAddress string `protobuf:"bytes,3,opt,name=spread_rewards_address,json=spreadRewardsAddress,proto3" json:"spread_rewards_address,omitempty" yaml:"spread_rewards_address"` + Id uint64 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty"` + // Amount of total liquidity + CurrentTickLiquidity cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=current_tick_liquidity,json=currentTickLiquidity,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"current_tick_liquidity" yaml:"current_tick_liquidity"` + Token0 string `protobuf:"bytes,6,opt,name=token0,proto3" json:"token0,omitempty"` + Token1 string `protobuf:"bytes,7,opt,name=token1,proto3" json:"token1,omitempty"` + CurrentSqrtPrice osmomath.BigDec `protobuf:"bytes,8,opt,name=current_sqrt_price,json=currentSqrtPrice,proto3,customtype=github.com/osmosis-labs/osmosis/osmomath.BigDec" json:"current_sqrt_price" yaml:"spot_price"` + CurrentTick int64 `protobuf:"varint,9,opt,name=current_tick,json=currentTick,proto3" json:"current_tick,omitempty" yaml:"current_tick"` + // tick_spacing must be one of the authorized_tick_spacing values set in the + // concentrated-liquidity parameters + TickSpacing uint64 `protobuf:"varint,10,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` + ExponentAtPriceOne int64 `protobuf:"varint,11,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3" json:"exponent_at_price_one,omitempty" yaml:"exponent_at_price_one"` + // spread_factor is the ratio that is charged on the amount of token in. + SpreadFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,12,opt,name=spread_factor,json=spreadFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spread_factor" yaml:"spread_factor"` + // last_liquidity_update is the last time either the pool liquidity or the + // active tick changed + LastLiquidityUpdate time.Time `protobuf:"bytes,13,opt,name=last_liquidity_update,json=lastLiquidityUpdate,proto3,stdtime" json:"last_liquidity_update" yaml:"last_liquidity_update"` +} + +func (m *OsmosisConcentratedLiquidityPool) Reset() { *m = OsmosisConcentratedLiquidityPool{} } +func (m *OsmosisConcentratedLiquidityPool) String() string { return proto.CompactTextString(m) } +func (*OsmosisConcentratedLiquidityPool) ProtoMessage() {} +func (*OsmosisConcentratedLiquidityPool) Descriptor() ([]byte, []int) { + return fileDescriptor_8b899353e6a19a1a, []int{0} +} +func (m *OsmosisConcentratedLiquidityPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OsmosisConcentratedLiquidityPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Pool.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 *OsmosisConcentratedLiquidityPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pool.Merge(m, src) +} +func (m *OsmosisConcentratedLiquidityPool) XXX_Size() int { + return m.Size() +} +func (m *OsmosisConcentratedLiquidityPool) XXX_DiscardUnknown() { + xxx_messageInfo_Pool.DiscardUnknown(m) +} + +var xxx_messageInfo_Pool proto.InternalMessageInfo + +func init() { + proto.RegisterType((*OsmosisConcentratedLiquidityPool)(nil), "osmosis.concentratedliquidity.v1beta1.Pool") +} + +func init() { + proto.RegisterFile("osmosis/concentratedliquidity/v1beta1/pool.proto", fileDescriptor_8b899353e6a19a1a) +} + +var fileDescriptor_8b899353e6a19a1a = []byte{ + // 661 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x4e, 0xdb, 0x40, + 0x10, 0x8e, 0xf9, 0x2d, 0x1b, 0x40, 0x65, 0x09, 0xd4, 0xd0, 0x12, 0xa7, 0x96, 0x2a, 0xe5, 0x50, + 0x6c, 0x42, 0x0f, 0x95, 0xe8, 0x89, 0x08, 0x55, 0xaa, 0x14, 0xa9, 0x68, 0xa1, 0xaa, 0x54, 0x55, + 0x72, 0x37, 0xf6, 0x62, 0x56, 0x71, 0xbc, 0xc6, 0xbb, 0xa1, 0xc0, 0x13, 0xf4, 0xc8, 0xb1, 0x47, + 0x1e, 0xa2, 0x0f, 0x81, 0x7a, 0x29, 0xc7, 0xaa, 0x07, 0xb7, 0x82, 0x37, 0xc8, 0x13, 0x54, 0xde, + 0x5d, 0x93, 0x20, 0x22, 0xb5, 0xa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 0xba, 0x27, 0x77, 0x1e, 0xad, 0xf5, 0xc1, 0xab, 0xd5, 0x65, + 0x01, 0x89, 0xda, 0x53, 0xb2, 0x87, 0x17, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xe2, 0x15, + 0xf7, 0xe3, 0x04, 0x00, 0x00, +} + +func (m *OsmosisConcentratedLiquidityPool) 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 *OsmosisConcentratedLiquidityPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OsmosisConcentratedLiquidityPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastLiquidityUpdate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastLiquidityUpdate):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintPool(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x6a + { + size := m.SpreadFactor.Size() + i -= size + if _, err := m.SpreadFactor.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + if m.ExponentAtPriceOne != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.ExponentAtPriceOne)) + i-- + dAtA[i] = 0x58 + } + if m.TickSpacing != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.TickSpacing)) + i-- + dAtA[i] = 0x50 + } + if m.CurrentTick != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.CurrentTick)) + i-- + dAtA[i] = 0x48 + } + { + size := m.CurrentSqrtPrice.Size() + i -= size + if _, err := m.CurrentSqrtPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if len(m.Token1) > 0 { + i -= len(m.Token1) + copy(dAtA[i:], m.Token1) + i = encodeVarintPool(dAtA, i, uint64(len(m.Token1))) + i-- + dAtA[i] = 0x3a + } + if len(m.Token0) > 0 { + i -= len(m.Token0) + copy(dAtA[i:], m.Token0) + i = encodeVarintPool(dAtA, i, uint64(len(m.Token0))) + i-- + dAtA[i] = 0x32 + } + { + size := m.CurrentTickLiquidity.Size() + i -= size + if _, err := m.CurrentTickLiquidity.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if m.Id != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x20 + } + if len(m.SpreadRewardsAddress) > 0 { + i -= len(m.SpreadRewardsAddress) + copy(dAtA[i:], m.SpreadRewardsAddress) + i = encodeVarintPool(dAtA, i, uint64(len(m.SpreadRewardsAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.IncentivesAddress) > 0 { + i -= len(m.IncentivesAddress) + copy(dAtA[i:], m.IncentivesAddress) + i = encodeVarintPool(dAtA, i, uint64(len(m.IncentivesAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintPool(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPool(dAtA []byte, offset int, v uint64) int { + offset -= sovPool(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OsmosisConcentratedLiquidityPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.IncentivesAddress) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.SpreadRewardsAddress) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovPool(uint64(m.Id)) + } + l = m.CurrentTickLiquidity.Size() + n += 1 + l + sovPool(uint64(l)) + l = len(m.Token0) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = len(m.Token1) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = m.CurrentSqrtPrice.Size() + n += 1 + l + sovPool(uint64(l)) + if m.CurrentTick != 0 { + n += 1 + sovPool(uint64(m.CurrentTick)) + } + if m.TickSpacing != 0 { + n += 1 + sovPool(uint64(m.TickSpacing)) + } + if m.ExponentAtPriceOne != 0 { + n += 1 + sovPool(uint64(m.ExponentAtPriceOne)) + } + l = m.SpreadFactor.Size() + n += 1 + l + sovPool(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastLiquidityUpdate) + n += 1 + l + sovPool(uint64(l)) + return n +} + +func sovPool(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPool(x uint64) (n int) { + return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *OsmosisConcentratedLiquidityPool) 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 ErrIntOverflowPool + } + 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: Pool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Pool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivesAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentivesAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpreadRewardsAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpreadRewardsAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentTickLiquidity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CurrentTickLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token0", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token0 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token1", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token1 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentSqrtPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CurrentSqrtPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentTick", wireType) + } + m.CurrentTick = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentTick |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TickSpacing", wireType) + } + m.TickSpacing = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TickSpacing |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExponentAtPriceOne", wireType) + } + m.ExponentAtPriceOne = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExponentAtPriceOne |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpreadFactor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SpreadFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastLiquidityUpdate", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastLiquidityUpdate, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPool(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPool + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPool + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPool + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPool + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPool + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPool + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPool = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPool = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index 792ff46fa3..e4f025d9a5 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -21,7 +21,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { // If never updated or update interval has passed if lastUpdate.IsZero() || !tokenPrice.QueryInProgress && currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) { // Update price for this specific token - err := k.SubmitSpotPriceV2CallbackICQ(ctx, tokenPrice) + err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice) if err != nil { // TODO handle error, maybe log it continue diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index af6e3c27bf..f65ad9c3c2 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -8,16 +8,18 @@ import ( "time" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/cosmos/gogoproto/proto" "github.com/Stride-Labs/stride/v24/utils" + deps "github.com/Stride-Labs/stride/v24/x/icqoracle/deps/types" "github.com/Stride-Labs/stride/v24/x/icqoracle/types" - icqkeeper "github.com/Stride-Labs/stride/v24/x/interchainquery/keeper" icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" ) const ( - ICQCallbackID_SpotPriceV2 = "spotpricev2" + ICQCallbackID_OsmosisClPool = "osmosisclpool" ) // ICQCallbacks wrapper struct for stakeibc keeper @@ -50,15 +52,15 @@ func (c ICQCallbacks) AddICQCallback(id string, fn interface{}) icqtypes.QueryCa func (c ICQCallbacks) RegisterICQCallbacks() icqtypes.QueryCallbacks { return c. - AddICQCallback(ICQCallbackID_SpotPriceV2, ICQCallback(SpotPriceV2Callback)) + AddICQCallback(ICQCallbackID_OsmosisClPool, ICQCallback(OsmosisClPoolCallback)) } -// Submits an ICQ to get a validator's shares to tokens rate -func (k Keeper) SubmitSpotPriceV2CallbackICQ( +// Submits an ICQ to get a concentrated liquidity pool from Osmosis' store +func (k Keeper) SubmitOsmosisClPoolICQ( ctx sdk.Context, tokenPrice types.TokenPrice, ) error { - k.Logger(ctx).Info(utils.LogWithPriceToken(tokenPrice, "Submitting SpotPriceV2 ICQ")) + k.Logger(ctx).Info(utils.LogWithPriceToken(tokenPrice, "Submitting OsmosisClPool ICQ")) params := k.GetParams(ctx) @@ -88,7 +90,7 @@ func (k Keeper) SubmitSpotPriceV2CallbackICQ( TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, } if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error submitting SpotPriceV2 ICQ, error '%s'", err.Error())) + k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error submitting OsmosisClPool ICQ, error '%s'", err.Error())) return err } @@ -111,7 +113,7 @@ func parseQueryID(id string) (baseDenom, quoteDenom, poolId, blockHeight string, return matches[1], matches[2], matches[3], matches[4], true } -func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { +func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { // TODO is this check even needed? if query.Id != query.CallbackId { return fmt.Errorf("query.Id ('%s') != query.CallbackId ('%s')", query.Id, query.CallbackId) @@ -148,8 +150,8 @@ func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes. return nil } - k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "SpotPriceV2", - "Starting SpotPriceV2 ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) + k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "OsmosisClPool", + "Starting OsmosisClPool ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) if err != nil { @@ -157,7 +159,7 @@ func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes. } // Unmarshal the query response args to determine the balance - newSpotPrice, err := icqkeeper.UnmarshalSpotPriceFromSpotPriceV2Query(k.cdc, args) + newSpotPrice, err := unmarshalSpotPriceFromOsmosisClPool(tokenPrice, args) if err != nil { return errorsmod.Wrap(err, "Error determining spot price from query response") } @@ -171,3 +173,17 @@ func SpotPriceV2Callback(k Keeper, ctx sdk.Context, args []byte, query icqtypes. return nil } + +func unmarshalSpotPriceFromOsmosisClPool(tokenPrice types.TokenPrice, queryResponseBz []byte) (price math.LegacyDec, err error) { + var pool deps.OsmosisConcentratedLiquidityPool + if err := proto.Unmarshal(queryResponseBz, &pool); err != nil { + return math.LegacyZeroDec(), err + } + + spotPrice, err := pool.SpotPrice(tokenPrice.OsmosisQuoteDenom, tokenPrice.OsmosisBaseDenom) + if err != nil { + return math.LegacyZeroDec(), err + } + + return spotPrice, nil +} diff --git a/x/interchainquery/keeper/queries.go b/x/interchainquery/keeper/queries.go index 24f1930a82..7a49d14757 100644 --- a/x/interchainquery/keeper/queries.go +++ b/x/interchainquery/keeper/queries.go @@ -178,8 +178,3 @@ func UnmarshalAmountFromBalanceQuery(cdc codec.BinaryCodec, queryResponseBz []by return sdkmath.Int{}, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unable to unmarshal balance query response %v as sdkmath.Int (err: %s) or sdk.Coin (err: %s)", queryResponseBz, intError.Error(), coinError.Error()) } - -func UnmarshalSpotPriceFromSpotPriceV2Query(cdc codec.BinaryCodec, queryResponseBz []byte) (price sdkmath.LegacyDec, err error) { - panic("TODO") - return sdkmath.LegacyDec{}, nil -} From 24fd9f35cb9249564b150bd17e0e445ffbca6109 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 09:15:56 +0200 Subject: [PATCH 009/115] update deps/osmosis to v27.0.0-no-fees --- .gitmodules | 2 +- deps/osmosis | 2 +- dockernet/dockerfiles/Dockerfile.osmo | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitmodules b/.gitmodules index d9925a32df..6a47fa9da8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,7 +17,7 @@ path = deps/juno url = https://github.com/CosmosContracts/juno.git [submodule "deps/osmosis"] - # Commit: v20.5.0-no-fees + # Commit: v27.0.0-no-fees path = deps/osmosis url = https://github.com/Stride-Labs/osmosis.git [submodule "deps/stargaze"] diff --git a/deps/osmosis b/deps/osmosis index 30532bd83e..2ce269b07f 160000 --- a/deps/osmosis +++ b/deps/osmosis @@ -1 +1 @@ -Subproject commit 30532bd83ebac4e8985fb9d4ead91bc2722810fb +Subproject commit 2ce269b07f4b6cec6649fbe7994dbf2e7d386e7d diff --git a/dockernet/dockerfiles/Dockerfile.osmo b/dockernet/dockerfiles/Dockerfile.osmo index e8e0278b3b..caf8d5c980 100644 --- a/dockernet/dockerfiles/Dockerfile.osmo +++ b/dockernet/dockerfiles/Dockerfile.osmo @@ -1,10 +1,10 @@ -FROM golang:1.20-alpine3.16 AS builder +FROM golang:1.23-alpine3.21 AS builder WORKDIR /opt/ RUN set -eux; apk add --no-cache ca-certificates build-base; apk add git linux-headers -ENV COMMIT_HASH=v20.5.0-no-fees +ENV COMMIT_HASH=v27.0.0-no-fees RUN git clone https://github.com/Stride-Labs/osmosis.git \ && cd osmosis \ @@ -13,16 +13,16 @@ RUN git clone https://github.com/Stride-Labs/osmosis.git \ WORKDIR /opt/osmosis # Cosmwasm - download correct libwasmvm version and verify checksum -# Note: checksum not available for v1.2.3, otherwise command should be -# wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt -# && sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1) -RUN WASMVM_VERSION=v1.2.3 \ - && wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \ - -O /lib/libwasmvm_muslc.a +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ + -O /lib/libwasmvm_muslc.$ARCH.a && \ + # verify checksum + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ + sha256sum /lib/libwasmvm_muslc.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1) RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build -FROM alpine:3.16 +FROM alpine:3.21 COPY --from=builder /opt/osmosis/build/osmosisd /usr/local/bin/ RUN apk add bash vim \ && addgroup -g 1000 osmosis \ From d5272cc8c5ada3db8a634b0bf02efc36dd5c0772 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 14:59:54 +0200 Subject: [PATCH 010/115] init x/auction --- proto/stride/auction/auction.proto | 47 + proto/stride/auction/genesis.proto | 16 + proto/stride/auction/query.proto | 76 ++ proto/stride/auction/tx.proto | 110 ++ x/auction/client/cli/query.go | 104 ++ x/auction/client/cli/tx.go | 110 ++ x/auction/keeper/genesis.go | 25 + x/auction/keeper/keeper.go | 147 ++ x/auction/keeper/msg_server.go | 82 ++ x/auction/keeper/params.go | 25 + x/auction/keeper/query.go | 84 ++ x/auction/module.go | 160 +++ x/auction/types/auction.pb.go | 857 ++++++++++++ x/auction/types/codec.go | 42 + x/auction/types/errors.go | 13 + x/auction/types/expected_keepers.go | 19 + x/auction/types/genesis.go | 12 + x/auction/types/genesis.pb.go | 386 ++++++ x/auction/types/keys.go | 25 + x/auction/types/msgs.go | 204 +++ x/auction/types/params.go | 16 + x/auction/types/query.pb.go | 1913 +++++++++++++++++++++++++++ x/auction/types/query.pb.gw.go | 456 +++++++ x/auction/types/tx.pb.go | 1739 ++++++++++++++++++++++++ 24 files changed, 6668 insertions(+) create mode 100644 proto/stride/auction/auction.proto create mode 100644 proto/stride/auction/genesis.proto create mode 100644 proto/stride/auction/query.proto create mode 100644 proto/stride/auction/tx.proto create mode 100644 x/auction/client/cli/query.go create mode 100644 x/auction/client/cli/tx.go create mode 100644 x/auction/keeper/genesis.go create mode 100644 x/auction/keeper/keeper.go create mode 100644 x/auction/keeper/msg_server.go create mode 100644 x/auction/keeper/params.go create mode 100644 x/auction/keeper/query.go create mode 100644 x/auction/module.go create mode 100644 x/auction/types/auction.pb.go create mode 100644 x/auction/types/codec.go create mode 100644 x/auction/types/errors.go create mode 100644 x/auction/types/expected_keepers.go create mode 100644 x/auction/types/genesis.go create mode 100644 x/auction/types/genesis.pb.go create mode 100644 x/auction/types/keys.go create mode 100644 x/auction/types/msgs.go create mode 100644 x/auction/types/params.go create mode 100644 x/auction/types/query.pb.go create mode 100644 x/auction/types/query.pb.gw.go create mode 100644 x/auction/types/tx.pb.go diff --git a/proto/stride/auction/auction.proto b/proto/stride/auction/auction.proto new file mode 100644 index 0000000000..d1e34a806b --- /dev/null +++ b/proto/stride/auction/auction.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package stride.auction; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; + +// Global auction parameters +message Params {} + +message Auction { + // Token denom being auctioned + string denom = 1; + + // Whether auction is active + bool enabled = 2; + + // Price multiplier (e.g. 0.95 for 5% discount) + string price_multiplier = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + // Minimum STRD bid amount + string min_bid_amount = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} + +// Stats tracks burning metrics +message Stats { + // Token denom being tracked + string token_denom = 1; + + // Total amount of STRD burned + string total_strd_burned = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + // Total amount of tokens sold + string total_tokens_sold = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/stride/auction/genesis.proto b/proto/stride/auction/genesis.proto new file mode 100644 index 0000000000..3d3fca6871 --- /dev/null +++ b/proto/stride/auction/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package stride.auction; + +import "gogoproto/gogo.proto"; +import "stride/auction/auction.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; + +// GenesisState defines the auction module's genesis state +message GenesisState { + // Module parameters + Params params = 1 [ (gogoproto.nullable) = false ]; + + // List of token auctions + repeated Auction auctions = 2 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/stride/auction/query.proto b/proto/stride/auction/query.proto new file mode 100644 index 0000000000..388db4aab3 --- /dev/null +++ b/proto/stride/auction/query.proto @@ -0,0 +1,76 @@ +syntax = "proto3"; +package stride.auction; + +import "stride/auction/auction.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; + +// Query defines the gRPC querier service. +service Query { + // Auction queries the auction info for a specific token + rpc Auction(QueryAuctionRequest) returns (QueryAuctionResponse) { + option (google.api.http).get = "/auction/v1beta1/auction/{denom}"; + } + + // Auctions queries the auction info for a specific token + rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) { + option (google.api.http).get = "/auction/v1beta1/auctions"; + } + + // Stats queries the auction stats for a specific token + rpc Stats(QueryStatsRequest) returns (QueryStatsResponse) { + option (google.api.http).get = "/auction/v1beta1/stats/{denom}"; + } + + // AllStats queries the auction stats for a specific token + rpc AllStats(QueryAllStatsRequest) returns (QueryAllStatsResponse) { + option (google.api.http).get = "/auction/v1beta1/stats"; + } +} + +// QueryAuctionRequest is the request type for the Query/Auction RPC +// method +message QueryAuctionRequest { string denom = 1; } + +// QueryAuctionResponse is the response type for the Query/Auction RPC +// method +message QueryAuctionResponse { + Auction auction = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryAuctionsRequest is the request type for the +// Query/Auctions RPC method +message QueryAuctionsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAuctionsResponse is the response type for the +// Query/Auctions RPC method +message QueryAuctionsResponse { + repeated Auction auctions = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryStatsRequest is the request type for the Query/TokenStats RPC +// method +message QueryStatsRequest { string denom = 1; } + +// QueryStatsResponse is the response type for the Query/TokenStats RPC +// method +message QueryStatsResponse { Stats stats = 1 [ (gogoproto.nullable) = false ]; } + +// QueryAllStatsRequest is the request type for the +// Query/Auctions RPC method +message QueryAllStatsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllStatsResponse is the response type for the +// Query/Auctions RPC method +message QueryAllStatsResponse { + repeated Stats all_stats = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/proto/stride/auction/tx.proto b/proto/stride/auction/tx.proto new file mode 100644 index 0000000000..33a1cb99f9 --- /dev/null +++ b/proto/stride/auction/tx.proto @@ -0,0 +1,110 @@ +syntax = "proto3"; +package stride.auction; + +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // User messages + + // PlaceBid places a bid to buy a token off an auction + rpc PlaceBid(MsgPlaceBid) returns (MsgPlaceBidResponse); + + // Admin messages + + // CreateAuction creates a new auction + rpc CreateAuction(MsgCreateAuction) returns (MsgCreateAuctionResponse); + // CreateAuction updates an existing auction + rpc UpdateAuction(MsgUpdateAuction) returns (MsgUpdateAuctionResponse); +} + +// MsgPlaceBid defines the message for bidding in a token auction +message MsgPlaceBid { + option (cosmos.msg.v1.signer) = "bidder"; + option (amino.name) = "stride/x/auction/MsgPlaceBid"; + + // Bidder's address + string bidder = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Token being bid on + string token_denom = 2; + + // Amount of tokens requested in base units (utoken) + string utoken_amount = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + // Amount of STRD being paid in base units (ustrd) + string ustrd_amount = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} + +message MsgPlaceBidResponse {} + +// MsgCreateAuction defines the message for adding a token auction +message MsgCreateAuction { + option (cosmos.msg.v1.signer) = "admin"; + option (amino.name) = "stride/x/auction/MsgCreateAuction"; + + // Admin's address + string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Denom on Stride of the token being auctioned (e.g. "ibc/...") + string denom = 2; + + // Whether auction is active + bool enabled = 3; + + // Price multiplier (e.g. 0.95 for 5% discount) + string price_multiplier = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + // Minimum STRD bid amount + string min_bid_amount = 5 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} + +message MsgCreateAuctionResponse {} + +// MsgUpdateAuction defines the message for adding a token auction +message MsgUpdateAuction { + option (cosmos.msg.v1.signer) = "admin"; + option (amino.name) = "stride/x/auction/MsgUpdateAuction"; + + // Admin's address + string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Token denom being updated + string denom = 2; + + // Whether auction is active + bool enabled = 3; + + // Price multiplier (e.g. 0.95 for 5% discount) + string price_multiplier = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + // Minimum STRD bid amount + string min_bid_amount = 5 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} + +message MsgUpdateAuctionResponse {} diff --git a/x/auction/client/cli/query.go b/x/auction/client/cli/query.go new file mode 100644 index 0000000000..c419015dd7 --- /dev/null +++ b/x/auction/client/cli/query.go @@ -0,0 +1,104 @@ +package cli + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdQueryTokenPrice(), + CmdQueryTokenPrices(), + CmdQueryParams(), + ) + + return cmd +} + +func CmdQueryTokenPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "token-price [base-denom] [quote-denom]", + Short: "Query the current price for a specific token", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + baseDenom := args[0] + quoteDenom := args[1] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryTokenPriceRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + res, err := queryClient.TokenPrice(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} + +func CmdQueryTokenPrices() *cobra.Command { + cmd := &cobra.Command{ + Use: "token-prices", + Short: "Query all token prices", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryTokenPricesRequest{} + res, err := queryClient.TokenPrices(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Get the parameters", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + req := &types.QueryParamsRequest{} + res, err := queryClient.Params(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go new file mode 100644 index 0000000000..ea63567bdc --- /dev/null +++ b/x/auction/client/cli/tx.go @@ -0,0 +1,110 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdAddTokenPrice(), + CmdRemoveTokenPrice(), + ) + + return cmd +} + +func CmdAddTokenPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-token-price [base-denom] [quote-denom] [osmosis-pool-id] [osmosis-base-denom] [osmosis-quote-denom]", + Short: "Add a token to price tracking", + Long: strings.TrimSpace( + fmt.Sprintf(`Add a token to price tracking. + +Example: + $ %[1]s tx %[2]s add-token-price uosmo uatom 123 uosmo ibc/... --from admin +`, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgAddTokenPrice( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + args[2], + args[3], + args[4], + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdRemoveTokenPrice() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove-token-price [base-denom] [quote-denom] [osmosis-pool-id]", + Short: "Remove a token from price tracking", + Long: strings.TrimSpace( + fmt.Sprintf(`Remove a token from price tracking. + +Example: + $ %[1]s tx %[2]s remove-token-price uatom uosmo 123 --from admin +`, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRemoveTokenPrice( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + args[2], + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go new file mode 100644 index 0000000000..53b4e6d889 --- /dev/null +++ b/x/auction/keeper/genesis.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +// Loads module state from genesis +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + k.SetParams(ctx, genState.Params) + for _, auction := range genState.Auctions { + if err := k.SetAuction(ctx, auction); err != nil { + panic(err) + } + } +} + +// Export's module state into genesis file +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + genesis.Auctions = k.GetAllAuctions(ctx) + return genesis +} diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go new file mode 100644 index 0000000000..1ca64083d4 --- /dev/null +++ b/x/auction/keeper/keeper.go @@ -0,0 +1,147 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// SetAuction stores auction info for a token +func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) error { + store := ctx.KVStore(k.storeKey) + key := types.AuctionKey(auction.Denom) + bz, err := k.cdc.Marshal(&auction) + if err != nil { + return err + } + + store.Set(key, bz) + return nil +} + +// GetAuction retrieves auction info for a token +func (k Keeper) GetAuction(ctx sdk.Context, denom string) (types.Auction, error) { + store := ctx.KVStore(k.storeKey) + key := types.AuctionKey(denom) + + bz := store.Get(key) + if bz == nil { + return types.Auction{}, fmt.Errorf("auction not found for denom='%s'", denom) + } + + var auction types.Auction + if err := k.cdc.Unmarshal(bz, &auction); err != nil { + return types.Auction{}, err + } + + return auction, nil +} + +// GetAllAuctions retrieves all stored auctions +func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyAuctionPrefix)) + defer iterator.Close() + + auctions := []types.Auction{} + for ; iterator.Valid(); iterator.Next() { + var auction types.Auction + k.cdc.MustUnmarshal(iterator.Value(), &auction) + auctions = append(auctions, auction) + } + + return auctions +} + +// GetStats retrieves stats info for an auction +func (k Keeper) GetStats(ctx sdk.Context, denom string) (types.Stats, error) { + store := ctx.KVStore(k.storeKey) + key := types.StatsKey(denom) + + bz := store.Get(key) + if bz == nil { + return types.Stats{}, fmt.Errorf("Stats not found for auction denom='%s'", denom) + } + + var stats types.Stats + if err := k.cdc.Unmarshal(bz, &stats); err != nil { + return types.Stats{}, err + } + + return stats, nil +} + +// GetAllStats retrieves all stored auctions stats +func (k Keeper) GetAllStats(ctx sdk.Context) []types.Stats { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyStatsPrefix)) + defer iterator.Close() + + allStats := []types.Stats{} + for ; iterator.Valid(); iterator.Next() { + var auctionStats types.Stats + k.cdc.MustUnmarshal(iterator.Value(), &auctionStats) + allStats = append(allStats, auctionStats) + } + + return allStats +} + +// SetAuction stores auction info for a token +func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { + // Get auction + auction, err := k.GetAuction(ctx, bid.TokenDenom) + if err != nil { + return fmt.Errorf("cannot get auction for denom='%s': %w", err) + } + + // Get token amount being auctioned off + moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) + balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.Denom) + tokenAmount := balance.Amount + + // Verify auction has enough tokens to service the bid amount + if bid.UtokenAmount.GT(tokenAmount) { + return fmt.Errorf("bid wants %s%s but auction has only %s%s", + bid.UtokenAmount.String(), + bid.TokenDenom, + tokenAmount.String(), + bid.TokenDenom, + ) + } + + // TODO continue + + return nil +} diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go new file mode 100644 index 0000000000..18987a28a8 --- /dev/null +++ b/x/auction/keeper/msg_server.go @@ -0,0 +1,82 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// PlaceBid places a bid to buy a token off an auction +func (ms msgServer) PlaceBid(goCtx context.Context, msg *types.MsgPlaceBid) (*types.MsgPlaceBidResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := ms.Keeper.PlaceBid(ctx, msg) + if err != nil { + return nil, err + } + + return &types.MsgPlaceBidResponse{}, nil +} + +// CreateAuction creates a new auction +func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO check admin + + _, err := ms.Keeper.GetAuction(ctx, msg.Denom) + if err == nil { + return nil, types.ErrAuctionAlreadyExists.Wrapf("auction for token '%s' already exists", msg.Denom) + } + + auction := types.Auction{ + Denom: msg.Denom, + Enabled: msg.Enabled, + PriceMultiplier: msg.PriceMultiplier, + MinBidAmount: msg.MinBidAmount, + } + + err = ms.Keeper.SetAuction(ctx, auction) + if err != nil { + return nil, err + } + + return &types.MsgCreateAuctionResponse{}, nil +} + +// CreateAuction updates an existing auction +func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuction) (*types.MsgUpdateAuctionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO check admin + + auction, err := ms.Keeper.GetAuction(ctx, msg.Denom) + if err != nil { + return nil, types.ErrAuctionDoesntExist.Wrapf("cannot find auction for token '%s'", msg.Denom) + } + + auction.Enabled = msg.Enabled + auction.MinBidAmount = msg.MinBidAmount + auction.PriceMultiplier = auction.PriceMultiplier + + err = ms.Keeper.SetAuction(ctx, auction) + if err != nil { + return nil, err + } + + return &types.MsgUpdateAuctionResponse{}, nil +} diff --git a/x/auction/keeper/params.go b/x/auction/keeper/params.go new file mode 100644 index 0000000000..cdcf0b467c --- /dev/null +++ b/x/auction/keeper/params.go @@ -0,0 +1,25 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +// Writes params to the store +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + paramsBz := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.ParamsPrefix), paramsBz) +} + +// Retrieves the module parameters +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + paramsBz := store.Get([]byte(types.ParamsPrefix)) + if len(paramsBz) == 0 { + panic("module parameters not set") + } + k.cdc.MustUnmarshal(paramsBz, ¶ms) + return params +} diff --git a/x/auction/keeper/query.go b/x/auction/keeper/query.go new file mode 100644 index 0000000000..c561822422 --- /dev/null +++ b/x/auction/keeper/query.go @@ -0,0 +1,84 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +var _ types.QueryServer = Keeper{} + +// Auction queries the auction info for a specific token +func (k Keeper) Auction(goCtx context.Context, req *types.QueryAuctionRequest) (*types.QueryAuctionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + auction, err := k.GetAuction(ctx, req.Denom) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + return &types.QueryAuctionResponse{ + Auction: auction, + }, nil +} + +// Auctions queries the auction info for a specific token +func (k Keeper) Auctions(goCtx context.Context, req *types.QueryAuctionsRequest) (*types.QueryAuctionsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + auctions := k.GetAllAuctions(ctx) + + // TODO impl paging + + return &types.QueryAuctionsResponse{ + Auctions: auctions, + }, nil +} + +// Stats queries the auction stats for a specific auction +func (k Keeper) Stats(goCtx context.Context, req *types.QueryStatsRequest) (*types.QueryStatsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + stats, err := k.GetStats(ctx, req.Denom) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + return &types.QueryStatsResponse{ + Stats: stats, + }, nil +} + +// AllStats queries the auction stats for all auctions +func (k Keeper) AllStats(goCtx context.Context, req *types.QueryAllStatsRequest) (*types.QueryAllStatsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + allStats := k.GetAllStats(ctx) + + // TODO impl paging + + return &types.QueryAllStatsResponse{ + AllStats: allStats, + }, nil +} diff --git a/x/auction/module.go b/x/auction/module.go new file mode 100644 index 0000000000..c217b4d36a --- /dev/null +++ b/x/auction/module.go @@ -0,0 +1,160 @@ +package auction + +import ( + "encoding/json" + "fmt" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Stride-Labs/stride/v24/x/auction/keeper" + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // TODO: Queries + // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + // panic(err) + // } +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + // TODO: messages + // return cli.GetTxCmd() + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + // TODO: Queries + // return cli.GetQueryCmd() + return nil +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + // TODO: Queries and Messages + // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + am.keeper.InitGenesis(ctx, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go new file mode 100644 index 0000000000..ee22ecfea8 --- /dev/null +++ b/x/auction/types/auction.pb.go @@ -0,0 +1,857 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/auction/auction.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Global auction parameters +type Params struct { +} + +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_739480caccbf7be9, []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 + +type Auction struct { + // Token denom being auctioned + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + // Whether auction is active + Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` + // Price multiplier (e.g. 0.95 for 5% discount) + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum STRD bid amount + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` +} + +func (m *Auction) Reset() { *m = Auction{} } +func (m *Auction) String() string { return proto.CompactTextString(m) } +func (*Auction) ProtoMessage() {} +func (*Auction) Descriptor() ([]byte, []int) { + return fileDescriptor_739480caccbf7be9, []int{1} +} +func (m *Auction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Auction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Auction.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 *Auction) XXX_Merge(src proto.Message) { + xxx_messageInfo_Auction.Merge(m, src) +} +func (m *Auction) XXX_Size() int { + return m.Size() +} +func (m *Auction) XXX_DiscardUnknown() { + xxx_messageInfo_Auction.DiscardUnknown(m) +} + +var xxx_messageInfo_Auction proto.InternalMessageInfo + +func (m *Auction) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *Auction) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +// Stats tracks burning metrics +type Stats struct { + // Token denom being tracked + TokenDenom string `protobuf:"bytes,1,opt,name=token_denom,json=tokenDenom,proto3" json:"token_denom,omitempty"` + // Total amount of STRD burned + TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` + // Total amount of tokens sold + TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` +} + +func (m *Stats) Reset() { *m = Stats{} } +func (m *Stats) String() string { return proto.CompactTextString(m) } +func (*Stats) ProtoMessage() {} +func (*Stats) Descriptor() ([]byte, []int) { + return fileDescriptor_739480caccbf7be9, []int{2} +} +func (m *Stats) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Stats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Stats.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 *Stats) XXX_Merge(src proto.Message) { + xxx_messageInfo_Stats.Merge(m, src) +} +func (m *Stats) XXX_Size() int { + return m.Size() +} +func (m *Stats) XXX_DiscardUnknown() { + xxx_messageInfo_Stats.DiscardUnknown(m) +} + +var xxx_messageInfo_Stats proto.InternalMessageInfo + +func (m *Stats) GetTokenDenom() string { + if m != nil { + return m.TokenDenom + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "stride.auction.Params") + proto.RegisterType((*Auction)(nil), "stride.auction.Auction") + proto.RegisterType((*Stats)(nil), "stride.auction.Stats") +} + +func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_739480caccbf7be9) } + +var fileDescriptor_739480caccbf7be9 = []byte{ + // 372 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbb, 0x0e, 0xd3, 0x30, + 0x14, 0x86, 0x63, 0xa0, 0x17, 0x0c, 0x6a, 0x21, 0x2a, 0x52, 0xc4, 0x25, 0xad, 0xca, 0xd2, 0x85, + 0x44, 0x5c, 0x5e, 0xa0, 0xa1, 0x4b, 0x45, 0x41, 0x28, 0x61, 0x62, 0x89, 0x9c, 0xd8, 0x4a, 0xad, + 0xc6, 0x76, 0x64, 0x9f, 0x20, 0xfa, 0x16, 0x3c, 0x11, 0x73, 0x27, 0xd4, 0x11, 0x31, 0x54, 0xa8, + 0x7d, 0x11, 0x54, 0x27, 0x2d, 0x48, 0x0c, 0x30, 0xd9, 0xe7, 0xf2, 0xfd, 0xd6, 0xef, 0x73, 0xf0, + 0x63, 0x03, 0x9a, 0x53, 0x16, 0x92, 0x3a, 0x07, 0xae, 0xe4, 0xe5, 0x0c, 0x2a, 0xad, 0x40, 0xb9, + 0x83, 0xa6, 0x1a, 0xb4, 0xd9, 0x87, 0xa3, 0x42, 0x15, 0xca, 0x96, 0xc2, 0xf3, 0xad, 0xe9, 0x9a, + 0xf6, 0x71, 0xf7, 0x3d, 0xd1, 0x44, 0x98, 0xe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 0x37, 0xbb, + 0xa3, 0x8f, 0xf6, 0x47, 0x1f, 0xfd, 0x3c, 0xfa, 0xe8, 0xcb, 0xc9, 0x77, 0xf6, 0x27, 0xdf, 0xf9, + 0x7e, 0xf2, 0x9d, 0x8f, 0xcf, 0x0b, 0x0e, 0xeb, 0x3a, 0x0b, 0x72, 0x25, 0xc2, 0xc4, 0x8e, 0xf9, + 0xd9, 0x8a, 0x64, 0x26, 0x6c, 0x17, 0xe2, 0xd3, 0x8b, 0x57, 0xe1, 0xe7, 0xeb, 0x5a, 0xc0, 0xb6, + 0x62, 0x26, 0xeb, 0xda, 0x79, 0xbf, 0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, 0x76, 0x15, 0xb1, 0x5e, + 0x35, 0x02, 0x00, 0x00, +} + +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 + return len(dAtA) - i, nil +} + +func (m *Auction) 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 *Auction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MinBidAmount.Size() + i -= size + if _, err := m.MinBidAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.PriceMultiplier.Size() + i -= size + if _, err := m.PriceMultiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintAuction(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Stats) 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 *Stats) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Stats) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalTokensSold.Size() + i -= size + if _, err := m.TotalTokensSold.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.TotalStrdBurned.Size() + i -= size + if _, err := m.TotalStrdBurned.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.TokenDenom) > 0 { + i -= len(m.TokenDenom) + copy(dAtA[i:], m.TokenDenom) + i = encodeVarintAuction(dAtA, i, uint64(len(m.TokenDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAuction(dAtA []byte, offset int, v uint64) int { + offset -= sovAuction(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *Auction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + if m.Enabled { + n += 2 + } + l = m.PriceMultiplier.Size() + n += 1 + l + sovAuction(uint64(l)) + l = m.MinBidAmount.Size() + n += 1 + l + sovAuction(uint64(l)) + return n +} + +func (m *Stats) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TokenDenom) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = m.TotalStrdBurned.Size() + n += 1 + l + sovAuction(uint64(l)) + l = m.TotalTokensSold.Size() + n += 1 + l + sovAuction(uint64(l)) + return n +} + +func sovAuction(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAuction(x uint64) (n int) { + return sovAuction(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 ErrIntOverflowAuction + } + 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 { + default: + iNdEx = preIndex + skippy, err := skipAuction(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuction + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Auction) 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 ErrIntOverflowAuction + } + 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: Auction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Auction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinBidAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuction(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuction + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Stats) 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 ErrIntOverflowAuction + } + 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: Stats: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Stats: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalStrdBurned", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalStrdBurned.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalTokensSold", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalTokensSold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuction(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuction + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAuction(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuction + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuction + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuction + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAuction + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAuction + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAuction + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAuction = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAuction = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAuction = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/auction/types/codec.go b/x/auction/types/codec.go new file mode 100644 index 0000000000..171d9f1dab --- /dev/null +++ b/x/auction/types/codec.go @@ -0,0 +1,42 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" +) + +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + legacy.RegisterAminoMsg(cdc, &MsgPlaceBid{}, "auction/MsgPlaceBid") + legacy.RegisterAminoMsg(cdc, &MsgCreateAuction{}, "auction/MsgCreateAuction") + legacy.RegisterAminoMsg(cdc, &MsgUpdateAuction{}, "auction/MsgUpdateAuction") +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgPlaceBid{}, + &MsgCreateAuction{}, + &MsgUpdateAuction{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be + // used to properly serialize MsgSubmitProposal instances + RegisterLegacyAminoCodec(govcodec.Amino) +} diff --git a/x/auction/types/errors.go b/x/auction/types/errors.go new file mode 100644 index 0000000000..9d35039f96 --- /dev/null +++ b/x/auction/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/auction module sentinel errors +var ( + ErrAuctionAlreadyExists = sdkerrors.Register(ModuleName, 7001, "auction already exists") + ErrAuctionDoesntExist = sdkerrors.Register(ModuleName, 7002, "auction doesn't exists") +) diff --git a/x/auction/types/expected_keepers.go b/x/auction/types/expected_keepers.go new file mode 100644 index 0000000000..3df04c0cf2 --- /dev/null +++ b/x/auction/types/expected_keepers.go @@ -0,0 +1,19 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Required BankKeeper functions +type AccountKeeper interface { + GetModuleAddress(moduleName string) sdk.AccAddress +} + +// Required BankKeeper functions +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetSupply(ctx sdk.Context, denom string) sdk.Coin + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error +} diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go new file mode 100644 index 0000000000..8837ec5300 --- /dev/null +++ b/x/auction/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Performs basic genesis state validation +func (gs GenesisState) Validate() error { + // TODO: ??? + return nil +} diff --git a/x/auction/types/genesis.pb.go b/x/auction/types/genesis.pb.go new file mode 100644 index 0000000000..57a415a4a2 --- /dev/null +++ b/x/auction/types/genesis.pb.go @@ -0,0 +1,386 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/auction/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the auction module's genesis state +type GenesisState struct { + // Module parameters + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // List of token auctions + Auctions []Auction `protobuf:"bytes,2,rep,name=auctions,proto3" json:"auctions"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_94bb6618fc080329, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetAuctions() []Auction { + if m != nil { + return m.Auctions + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "stride.auction.GenesisState") +} + +func init() { proto.RegisterFile("stride/auction/genesis.proto", fileDescriptor_94bb6618fc080329) } + +var fileDescriptor_94bb6618fc080329 = []byte{ + // 220 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x2e, 0x29, 0xca, + 0x4c, 0x49, 0xd5, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, + 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xea, 0x41, 0x65, 0xa5, + 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x14, 0xba, 0x19, 0x50, + 0x1a, 0x22, 0xab, 0x54, 0xcf, 0xc5, 0xe3, 0x0e, 0x31, 0x34, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, + 0x84, 0x8b, 0xad, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, + 0x4c, 0x0f, 0xd5, 0x12, 0xbd, 0x00, 0xb0, 0xac, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x50, + 0xb5, 0x42, 0x96, 0x5c, 0x1c, 0x50, 0xf9, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x71, + 0x74, 0x7d, 0x8e, 0x10, 0x1a, 0xaa, 0x11, 0xae, 0xdc, 0xc9, 0xfb, 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, 0x0c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, + 0xf5, 0x83, 0xc1, 0x86, 0xe9, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0xfd, 0x53, 0x66, 0x64, 0xa2, + 0x5f, 0x01, 0xf7, 0x55, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x53, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x1b, 0xbc, 0x9c, 0x7c, 0x38, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Auctions) > 0 { + for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.Auctions) > 0 { + for _, e := range m.Auctions { + 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 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Auctions", 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.Auctions = append(m.Auctions, Auction{}) + if err := m.Auctions[len(m.Auctions)-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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/auction/types/keys.go b/x/auction/types/keys.go new file mode 100644 index 0000000000..e8ed84e6ba --- /dev/null +++ b/x/auction/types/keys.go @@ -0,0 +1,25 @@ +package types + +import fmt "fmt" + +const ( + ModuleName = "auction" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the routing key + RouterKey = ModuleName + + ParamsPrefix = "params" + KeyAuctionPrefix = "auction" + KeyStatsPrefix = "stats" +) + +func AuctionKey(denom string) []byte { + return []byte(fmt.Sprintf("%s%s", KeyAuctionPrefix, denom)) +} + +func StatsKey(denom string) []byte { + return []byte(fmt.Sprintf("%s%s", KeyStatsPrefix, denom)) +} diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go new file mode 100644 index 0000000000..735b9ac0de --- /dev/null +++ b/x/auction/types/msgs.go @@ -0,0 +1,204 @@ +package types + +import ( + "errors" + "fmt" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" +) + +const ( + TypeMsgPlaceBid = "place_bid" + TypeMsgCreateAuction = "create_auction" + TypeMsgUpdateAuction = "update_auction" +) + +var ( + _ sdk.Msg = &MsgPlaceBid{} + _ sdk.Msg = &MsgCreateAuction{} + _ sdk.Msg = &MsgUpdateAuction{} + + // Implement legacy interface for ledger support + _ legacytx.LegacyMsg = &MsgPlaceBid{} + _ legacytx.LegacyMsg = &MsgCreateAuction{} + _ legacytx.LegacyMsg = &MsgUpdateAuction{} +) + +// ---------------------------------------------- +// MsgPlaceBid +// ---------------------------------------------- + +func NewMsgPlaceBid(bidder, tokenDenom string, utokenAmount, ustrdAmount uint64) *MsgPlaceBid { + return &MsgPlaceBid{ + Bidder: bidder, + TokenDenom: tokenDenom, + UtokenAmount: math.NewIntFromUint64(utokenAmount), + UstrdAmount: math.NewIntFromUint64(ustrdAmount), + } +} + +func (msg MsgPlaceBid) Type() string { + return TypeMsgPlaceBid +} + +func (msg MsgPlaceBid) Route() string { + return RouterKey +} + +func (msg *MsgPlaceBid) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Bidder) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgPlaceBid) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgPlaceBid) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Bidder); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } + if msg.TokenDenom == "" { + return errors.New("token-denom must be specified") + } + if msg.UtokenAmount.IsZero() { + return errors.New("utoken-amount cannot be 0") + } + if msg.UstrdAmount.IsZero() { + return errors.New("ustrd-amount cannot be 0") + } + + return nil +} + +// ---------------------------------------------- +// MsgCreateAuction +// ---------------------------------------------- + +func NewMsgCreateAuction(admin string, + denom string, + enabled bool, + priceMultiplier string, + minBidAmount uint64, +) *MsgCreateAuction { + priceMultiplierDec, err := math.LegacyNewDecFromStr(priceMultiplier) + if err != nil { + panic(fmt.Sprintf("cannot parse LegacyDecimal from priceMultiplier '%s'", priceMultiplier)) + } + + return &MsgCreateAuction{ + Admin: admin, + Denom: denom, + Enabled: enabled, + PriceMultiplier: priceMultiplierDec, + MinBidAmount: math.NewIntFromUint64(minBidAmount), + } +} + +func (msg MsgCreateAuction) Type() string { + return TypeMsgCreateAuction +} + +func (msg MsgCreateAuction) Route() string { + return RouterKey +} + +func (msg *MsgCreateAuction) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgCreateAuction) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreateAuction) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } + if msg.Denom == "" { + return errors.New("denom must be specified") + } + if msg.MinBidAmount.LT(math.ZeroInt()) { + return errors.New("min-bid-amount must be at least 0") + } + if msg.PriceMultiplier.IsZero() { + return errors.New("price-multiplier cannot be 0") + } + + return nil +} + +// ---------------------------------------------- +// MsgUpdateAuction +// ---------------------------------------------- + +func NewMsgUpdateAuction(admin string, + denom string, + enabled bool, + priceMultiplier string, + minBidAmount uint64, +) *MsgUpdateAuction { + priceMultiplierDec, err := math.LegacyNewDecFromStr(priceMultiplier) + if err != nil { + panic(fmt.Sprintf("cannot parse LegacyDecimal from priceMultiplier '%s'", priceMultiplier)) + } + + return &MsgUpdateAuction{ + Admin: admin, + Denom: denom, + Enabled: enabled, + PriceMultiplier: priceMultiplierDec, + MinBidAmount: math.NewIntFromUint64(minBidAmount), + } +} + +func (msg MsgUpdateAuction) Type() string { + return TypeMsgUpdateAuction +} + +func (msg MsgUpdateAuction) Route() string { + return RouterKey +} + +func (msg *MsgUpdateAuction) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Admin) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateAuction) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateAuction) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } + if msg.Denom == "" { + return errors.New("denom must be specified") + } + if msg.MinBidAmount.LT(math.ZeroInt()) { + return errors.New("min-bid-amount must be at least 0") + } + if msg.PriceMultiplier.IsZero() { + return errors.New("price-multiplier cannot be 0") + } + + return nil +} diff --git a/x/auction/types/params.go b/x/auction/types/params.go new file mode 100644 index 0000000000..874012a4b8 --- /dev/null +++ b/x/auction/types/params.go @@ -0,0 +1,16 @@ +package types + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go new file mode 100644 index 0000000000..ef9a52caf7 --- /dev/null +++ b/x/auction/types/query.pb.go @@ -0,0 +1,1913 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/auction/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryAuctionRequest is the request type for the Query/Auction RPC +// method +type QueryAuctionRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryAuctionRequest) Reset() { *m = QueryAuctionRequest{} } +func (m *QueryAuctionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionRequest) ProtoMessage() {} +func (*QueryAuctionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{0} +} +func (m *QueryAuctionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionRequest.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 *QueryAuctionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionRequest.Merge(m, src) +} +func (m *QueryAuctionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionRequest proto.InternalMessageInfo + +func (m *QueryAuctionRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryAuctionResponse is the response type for the Query/Auction RPC +// method +type QueryAuctionResponse struct { + Auction Auction `protobuf:"bytes,1,opt,name=auction,proto3" json:"auction"` +} + +func (m *QueryAuctionResponse) Reset() { *m = QueryAuctionResponse{} } +func (m *QueryAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionResponse) ProtoMessage() {} +func (*QueryAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{1} +} +func (m *QueryAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionResponse.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 *QueryAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionResponse.Merge(m, src) +} +func (m *QueryAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionResponse proto.InternalMessageInfo + +func (m *QueryAuctionResponse) GetAuction() Auction { + if m != nil { + return m.Auction + } + return Auction{} +} + +// QueryAuctionsRequest is the request type for the +// Query/Auctions RPC method +type QueryAuctionsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAuctionsRequest) Reset() { *m = QueryAuctionsRequest{} } +func (m *QueryAuctionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionsRequest) ProtoMessage() {} +func (*QueryAuctionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{2} +} +func (m *QueryAuctionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionsRequest.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 *QueryAuctionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionsRequest.Merge(m, src) +} +func (m *QueryAuctionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionsRequest proto.InternalMessageInfo + +func (m *QueryAuctionsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAuctionsResponse is the response type for the +// Query/Auctions RPC method +type QueryAuctionsResponse struct { + Auctions []Auction `protobuf:"bytes,1,rep,name=auctions,proto3" json:"auctions"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAuctionsResponse) Reset() { *m = QueryAuctionsResponse{} } +func (m *QueryAuctionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAuctionsResponse) ProtoMessage() {} +func (*QueryAuctionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{3} +} +func (m *QueryAuctionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAuctionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAuctionsResponse.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 *QueryAuctionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAuctionsResponse.Merge(m, src) +} +func (m *QueryAuctionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAuctionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAuctionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAuctionsResponse proto.InternalMessageInfo + +func (m *QueryAuctionsResponse) GetAuctions() []Auction { + if m != nil { + return m.Auctions + } + return nil +} + +func (m *QueryAuctionsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryStatsRequest is the request type for the Query/TokenStats RPC +// method +type QueryStatsRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryStatsRequest) Reset() { *m = QueryStatsRequest{} } +func (m *QueryStatsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStatsRequest) ProtoMessage() {} +func (*QueryStatsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{4} +} +func (m *QueryStatsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStatsRequest.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 *QueryStatsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStatsRequest.Merge(m, src) +} +func (m *QueryStatsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStatsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStatsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStatsRequest proto.InternalMessageInfo + +func (m *QueryStatsRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryStatsResponse is the response type for the Query/TokenStats RPC +// method +type QueryStatsResponse struct { + Stats Stats `protobuf:"bytes,1,opt,name=stats,proto3" json:"stats"` +} + +func (m *QueryStatsResponse) Reset() { *m = QueryStatsResponse{} } +func (m *QueryStatsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStatsResponse) ProtoMessage() {} +func (*QueryStatsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{5} +} +func (m *QueryStatsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStatsResponse.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 *QueryStatsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStatsResponse.Merge(m, src) +} +func (m *QueryStatsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStatsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStatsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStatsResponse proto.InternalMessageInfo + +func (m *QueryStatsResponse) GetStats() Stats { + if m != nil { + return m.Stats + } + return Stats{} +} + +// QueryAllStatsRequest is the request type for the +// Query/Auctions RPC method +type QueryAllStatsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllStatsRequest) Reset() { *m = QueryAllStatsRequest{} } +func (m *QueryAllStatsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllStatsRequest) ProtoMessage() {} +func (*QueryAllStatsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{6} +} +func (m *QueryAllStatsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllStatsRequest.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 *QueryAllStatsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllStatsRequest.Merge(m, src) +} +func (m *QueryAllStatsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllStatsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllStatsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllStatsRequest proto.InternalMessageInfo + +func (m *QueryAllStatsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAllStatsResponse is the response type for the +// Query/Auctions RPC method +type QueryAllStatsResponse struct { + AllStats []Stats `protobuf:"bytes,1,rep,name=all_stats,json=allStats,proto3" json:"all_stats"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllStatsResponse) Reset() { *m = QueryAllStatsResponse{} } +func (m *QueryAllStatsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllStatsResponse) ProtoMessage() {} +func (*QueryAllStatsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8113674a9412675c, []int{7} +} +func (m *QueryAllStatsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllStatsResponse.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 *QueryAllStatsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllStatsResponse.Merge(m, src) +} +func (m *QueryAllStatsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllStatsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllStatsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllStatsResponse proto.InternalMessageInfo + +func (m *QueryAllStatsResponse) GetAllStats() []Stats { + if m != nil { + return m.AllStats + } + return nil +} + +func (m *QueryAllStatsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryAuctionRequest)(nil), "stride.auction.QueryAuctionRequest") + proto.RegisterType((*QueryAuctionResponse)(nil), "stride.auction.QueryAuctionResponse") + proto.RegisterType((*QueryAuctionsRequest)(nil), "stride.auction.QueryAuctionsRequest") + proto.RegisterType((*QueryAuctionsResponse)(nil), "stride.auction.QueryAuctionsResponse") + proto.RegisterType((*QueryStatsRequest)(nil), "stride.auction.QueryStatsRequest") + proto.RegisterType((*QueryStatsResponse)(nil), "stride.auction.QueryStatsResponse") + proto.RegisterType((*QueryAllStatsRequest)(nil), "stride.auction.QueryAllStatsRequest") + proto.RegisterType((*QueryAllStatsResponse)(nil), "stride.auction.QueryAllStatsResponse") +} + +func init() { proto.RegisterFile("stride/auction/query.proto", fileDescriptor_8113674a9412675c) } + +var fileDescriptor_8113674a9412675c = []byte{ + // 550 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0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b, 0xae, 0x16, 0x21, 0x66, 0xdc, 0x07, 0xfb, 0xda, 0x62, 0x91, 0xf1, 0x72, + 0xb7, 0x3f, 0xff, 0xf8, 0xf3, 0x75, 0xc5, 0x25, 0x8d, 0xec, 0x32, 0xa7, 0xf7, 0x2e, 0x7d, 0xfe, + 0xa0, 0x8f, 0xf3, 0x23, 0x79, 0x0f, 0xd5, 0x74, 0x24, 0xc9, 0xc2, 0xda, 0xe9, 0x01, 0xd9, 0xd7, + 0x97, 0xa8, 0x10, 0x61, 0x53, 0x23, 0x5c, 0x26, 0x97, 0xe6, 0x21, 0x48, 0x32, 0x84, 0x8a, 0xe9, + 0xeb, 0xe6, 0xcc, 0x92, 0xd3, 0x63, 0x61, 0xbb, 0x8b, 0x24, 0x68, 0xb9, 0xa5, 0x2d, 0x1b, 0xc4, + 0xf9, 0xcf, 0x52, 0x9f, 0x75, 0x96, 0xf9, 0x2d, 0x54, 0xd3, 0xa1, 0x98, 0x97, 0x39, 0x3f, 0x94, + 0xf3, 0x32, 0x17, 0x26, 0xcb, 0x75, 0x34, 0x40, 0x9d, 0x5c, 0x98, 0x0d, 0xb0, 0xf3, 0xe4, 0x68, + 0xe4, 0x58, 0xc7, 0x23, 0xc7, 0xfa, 0x3d, 0x72, 0xac, 0x2f, 0x63, 0xa7, 0x74, 0x3c, 0x76, 0x4a, + 0x3f, 0xc7, 0x4e, 0xe9, 0x65, 0xd3, 0x0f, 0xd4, 0x9b, 0x41, 0xc7, 0xeb, 0x8a, 0x1e, 0xdd, 0xd3, + 0x56, 0x77, 0x9e, 0xb2, 0x8e, 0xa4, 0xf8, 0x49, 0x1e, 0xb6, 0xee, 0xd1, 0x77, 0x59, 0x51, 0x75, + 0x18, 0x73, 0xd9, 0x39, 0xad, 0xbf, 0x9b, 0x77, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x93, 0x01, + 0x5c, 0xa0, 0xe3, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Auction queries the auction info for a specific token + Auction(ctx context.Context, in *QueryAuctionRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) + // Auctions queries the auction info for a specific token + Auctions(ctx context.Context, in *QueryAuctionsRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) + // Stats queries the auction stats for a specific token + Stats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) + // AllStats queries the auction stats for a specific token + AllStats(ctx context.Context, in *QueryAllStatsRequest, opts ...grpc.CallOption) (*QueryAllStatsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Auction(ctx context.Context, in *QueryAuctionRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) { + out := new(QueryAuctionResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Query/Auction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Auctions(ctx context.Context, in *QueryAuctionsRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) { + out := new(QueryAuctionsResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Query/Auctions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Stats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) { + out := new(QueryStatsResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Query/Stats", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AllStats(ctx context.Context, in *QueryAllStatsRequest, opts ...grpc.CallOption) (*QueryAllStatsResponse, error) { + out := new(QueryAllStatsResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Query/AllStats", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Auction queries the auction info for a specific token + Auction(context.Context, *QueryAuctionRequest) (*QueryAuctionResponse, error) + // Auctions queries the auction info for a specific token + Auctions(context.Context, *QueryAuctionsRequest) (*QueryAuctionsResponse, error) + // Stats queries the auction stats for a specific token + Stats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) + // AllStats queries the auction stats for a specific token + AllStats(context.Context, *QueryAllStatsRequest) (*QueryAllStatsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Auction(ctx context.Context, req *QueryAuctionRequest) (*QueryAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Auction not implemented") +} +func (*UnimplementedQueryServer) Auctions(ctx context.Context, req *QueryAuctionsRequest) (*QueryAuctionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Auctions not implemented") +} +func (*UnimplementedQueryServer) Stats(ctx context.Context, req *QueryStatsRequest) (*QueryStatsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Stats not implemented") +} +func (*UnimplementedQueryServer) AllStats(ctx context.Context, req *QueryAllStatsRequest) (*QueryAllStatsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllStats not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Auction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Auction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Query/Auction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Auction(ctx, req.(*QueryAuctionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Auctions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Auctions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Query/Auctions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Auctions(ctx, req.(*QueryAuctionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Stats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStatsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Stats(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Query/Stats", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Stats(ctx, req.(*QueryStatsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AllStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllStatsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllStats(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Query/AllStats", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllStats(ctx, req.(*QueryAllStatsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "stride.auction.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Auction", + Handler: _Query_Auction_Handler, + }, + { + MethodName: "Auctions", + Handler: _Query_Auctions_Handler, + }, + { + MethodName: "Stats", + Handler: _Query_Stats_Handler, + }, + { + MethodName: "AllStats", + Handler: _Query_AllStats_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "stride/auction/query.proto", +} + +func (m *QueryAuctionRequest) 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 *QueryAuctionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionResponse) 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 *QueryAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Auction.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAuctionsRequest) 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 *QueryAuctionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAuctionsResponse) 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 *QueryAuctionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Auctions) > 0 { + for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryStatsRequest) 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 *QueryStatsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryStatsResponse) 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 *QueryStatsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Stats.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAllStatsRequest) 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 *QueryAllStatsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllStatsResponse) 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 *QueryAllStatsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.AllStats) > 0 { + for iNdEx := len(m.AllStats) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AllStats[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryAuctionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Auction.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAuctionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Auctions) > 0 { + for _, e := range m.Auctions { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStatsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStatsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Stats.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllStatsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllStatsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AllStats) > 0 { + for _, e := range m.AllStats { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryAuctionRequest) 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: QueryAuctionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + 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 *QueryAuctionResponse) 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: QueryAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Auction", 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 := m.Auction.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 (m *QueryAuctionsRequest) 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: QueryAuctionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryAuctionsResponse) 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: QueryAuctionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAuctionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Auctions", 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 + } + m.Auctions = append(m.Auctions, Auction{}) + if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryStatsRequest) 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: QueryStatsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + 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 *QueryStatsResponse) 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: QueryStatsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stats", 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 := m.Stats.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 (m *QueryAllStatsRequest) 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: QueryAllStatsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryAllStatsResponse) 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: QueryAllStatsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllStats", 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 + } + m.AllStats = append(m.AllStats, Stats{}) + if err := m.AllStats[len(m.AllStats)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/auction/types/query.pb.gw.go b/x/auction/types/query.pb.gw.go new file mode 100644 index 0000000000..de7b6bfe26 --- /dev/null +++ b/x/auction/types/query.pb.gw.go @@ -0,0 +1,456 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: stride/auction/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.Auction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.Auction(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Auctions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Auctions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Auctions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAuctionsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Auctions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Auctions(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Stats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStatsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.Stats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Stats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStatsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.Stats(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AllStats_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_AllStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllStatsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllStats_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AllStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AllStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllStatsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllStats_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AllStats(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Auction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Auction_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Auctions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Auctions_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Stats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Stats_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Stats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AllStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AllStats_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Auction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Auction_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Auctions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Auctions_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Auctions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Stats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Stats_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Stats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AllStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AllStats_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0, 1, 0, 4, 1, 5, 2}, []string{"auction", "v1beta1", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auction", "v1beta1", "auctions"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Stats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"auction", "v1beta1", "stats", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AllStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auction", "v1beta1", "stats"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Auction_0 = runtime.ForwardResponseMessage + + forward_Query_Auctions_0 = runtime.ForwardResponseMessage + + forward_Query_Stats_0 = runtime.ForwardResponseMessage + + forward_Query_AllStats_0 = runtime.ForwardResponseMessage +) diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go new file mode 100644 index 0000000000..6abd255007 --- /dev/null +++ b/x/auction/types/tx.pb.go @@ -0,0 +1,1739 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/auction/tx.proto + +package types + +import ( + context "context" + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgPlaceBid defines the message for bidding in a token auction +type MsgPlaceBid struct { + // Bidder's address + Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` + // Token being bid on + TokenDenom string `protobuf:"bytes,2,opt,name=token_denom,json=tokenDenom,proto3" json:"token_denom,omitempty"` + // Amount of tokens requested in base units (utoken) + UtokenAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=utoken_amount,json=utokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"utoken_amount"` + // Amount of STRD being paid in base units (ustrd) + UstrdAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=ustrd_amount,json=ustrdAmount,proto3,customtype=cosmossdk.io/math.Int" json:"ustrd_amount"` +} + +func (m *MsgPlaceBid) Reset() { *m = MsgPlaceBid{} } +func (m *MsgPlaceBid) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceBid) ProtoMessage() {} +func (*MsgPlaceBid) Descriptor() ([]byte, []int) { + return fileDescriptor_07b888fb549a7ca8, []int{0} +} +func (m *MsgPlaceBid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceBid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceBid.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 *MsgPlaceBid) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceBid.Merge(m, src) +} +func (m *MsgPlaceBid) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceBid) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceBid.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceBid proto.InternalMessageInfo + +func (m *MsgPlaceBid) GetBidder() string { + if m != nil { + return m.Bidder + } + return "" +} + +func (m *MsgPlaceBid) GetTokenDenom() string { + if m != nil { + return m.TokenDenom + } + return "" +} + +type MsgPlaceBidResponse struct { +} + +func (m *MsgPlaceBidResponse) Reset() { *m = MsgPlaceBidResponse{} } +func (m *MsgPlaceBidResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceBidResponse) ProtoMessage() {} +func (*MsgPlaceBidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_07b888fb549a7ca8, []int{1} +} +func (m *MsgPlaceBidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceBidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceBidResponse.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 *MsgPlaceBidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceBidResponse.Merge(m, src) +} +func (m *MsgPlaceBidResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceBidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceBidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceBidResponse proto.InternalMessageInfo + +// MsgCreateAuction defines the message for adding a token auction +type MsgCreateAuction struct { + // Admin's address + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // Denom on Stride of the token being auctioned (e.g. "ibc/...") + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Whether auction is active + Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` + // Price multiplier (e.g. 0.95 for 5% discount) + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum STRD bid amount + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` +} + +func (m *MsgCreateAuction) Reset() { *m = MsgCreateAuction{} } +func (m *MsgCreateAuction) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAuction) ProtoMessage() {} +func (*MsgCreateAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_07b888fb549a7ca8, []int{2} +} +func (m *MsgCreateAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAuction.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 *MsgCreateAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAuction.Merge(m, src) +} +func (m *MsgCreateAuction) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAuction) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAuction proto.InternalMessageInfo + +func (m *MsgCreateAuction) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgCreateAuction) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgCreateAuction) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +type MsgCreateAuctionResponse struct { +} + +func (m *MsgCreateAuctionResponse) Reset() { *m = MsgCreateAuctionResponse{} } +func (m *MsgCreateAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAuctionResponse) ProtoMessage() {} +func (*MsgCreateAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_07b888fb549a7ca8, []int{3} +} +func (m *MsgCreateAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAuctionResponse.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 *MsgCreateAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAuctionResponse.Merge(m, src) +} +func (m *MsgCreateAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAuctionResponse proto.InternalMessageInfo + +// MsgUpdateAuction defines the message for adding a token auction +type MsgUpdateAuction struct { + // Admin's address + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // Token denom being updated + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Whether auction is active + Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` + // Price multiplier (e.g. 0.95 for 5% discount) + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum STRD bid amount + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` +} + +func (m *MsgUpdateAuction) Reset() { *m = MsgUpdateAuction{} } +func (m *MsgUpdateAuction) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAuction) ProtoMessage() {} +func (*MsgUpdateAuction) Descriptor() ([]byte, []int) { + return fileDescriptor_07b888fb549a7ca8, []int{4} +} +func (m *MsgUpdateAuction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAuction.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 *MsgUpdateAuction) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAuction.Merge(m, src) +} +func (m *MsgUpdateAuction) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAuction) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAuction.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAuction proto.InternalMessageInfo + +func (m *MsgUpdateAuction) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *MsgUpdateAuction) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgUpdateAuction) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +type MsgUpdateAuctionResponse struct { +} + +func (m *MsgUpdateAuctionResponse) Reset() { *m = MsgUpdateAuctionResponse{} } +func (m *MsgUpdateAuctionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAuctionResponse) ProtoMessage() {} +func (*MsgUpdateAuctionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_07b888fb549a7ca8, []int{5} +} +func (m *MsgUpdateAuctionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAuctionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAuctionResponse.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 *MsgUpdateAuctionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAuctionResponse.Merge(m, src) +} +func (m *MsgUpdateAuctionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAuctionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAuctionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAuctionResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgPlaceBid)(nil), "stride.auction.MsgPlaceBid") + proto.RegisterType((*MsgPlaceBidResponse)(nil), "stride.auction.MsgPlaceBidResponse") + proto.RegisterType((*MsgCreateAuction)(nil), "stride.auction.MsgCreateAuction") + proto.RegisterType((*MsgCreateAuctionResponse)(nil), "stride.auction.MsgCreateAuctionResponse") + proto.RegisterType((*MsgUpdateAuction)(nil), "stride.auction.MsgUpdateAuction") + proto.RegisterType((*MsgUpdateAuctionResponse)(nil), "stride.auction.MsgUpdateAuctionResponse") +} + +func init() { proto.RegisterFile("stride/auction/tx.proto", fileDescriptor_07b888fb549a7ca8) } + +var fileDescriptor_07b888fb549a7ca8 = []byte{ + // 574 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0xe3, 0x94, 0x94, 0x72, 0xfd, 0x43, 0x39, 0x52, 0xd5, 0xb8, 0xe0, 0x94, 0x74, 0xa9, + 0x22, 0x6a, 0xb7, 0x85, 0x89, 0x89, 0xa4, 0x5d, 0x10, 0x09, 0x42, 0xae, 0x58, 0x60, 0x88, 0x6c, + 0xdf, 0xc9, 0x3d, 0x35, 0xbe, 0xb3, 0x7c, 0xe7, 0xaa, 0xdd, 0x10, 0x23, 0x13, 0x43, 0x3f, 0x48, + 0x06, 0x16, 0xbe, 0x41, 0xc7, 0x8a, 0x09, 0x31, 0x54, 0x28, 0x19, 0xf2, 0x35, 0x90, 0x7d, 0x97, + 0xc8, 0x2e, 0x11, 0xe9, 0x07, 0x60, 0x49, 0xf2, 0xbe, 0xf7, 0x3c, 0x8f, 0xf2, 0xfe, 0x5e, 0xfb, + 0xc0, 0x3a, 0x17, 0x31, 0x41, 0xd8, 0x76, 0x13, 0x5f, 0x10, 0x46, 0x6d, 0x71, 0x66, 0x45, 0x31, + 0x13, 0x0c, 0xae, 0xc8, 0x03, 0x4b, 0x1d, 0x18, 0xeb, 0x3e, 0xe3, 0x21, 0xe3, 0x76, 0xc8, 0x03, + 0xfb, 0x74, 0x2f, 0xfd, 0x92, 0x42, 0xe3, 0x81, 0x1b, 0x12, 0xca, 0xec, 0xec, 0x53, 0xb5, 0x1e, + 0x49, 0x6d, 0x37, 0xab, 0x6c, 0x59, 0xa8, 0xa3, 0x6a, 0xc0, 0x02, 0x26, 0xfb, 0xe9, 0x2f, 0xd9, + 0xad, 0x5f, 0x94, 0xc1, 0x62, 0x87, 0x07, 0xef, 0x7a, 0xae, 0x8f, 0x5b, 0x04, 0xc1, 0x5d, 0x30, + 0xef, 0x11, 0x84, 0x70, 0xac, 0x6b, 0x9b, 0xda, 0xf6, 0xbd, 0x96, 0xfe, 0xe3, 0xdb, 0x4e, 0x55, + 0xe5, 0x34, 0x11, 0x8a, 0x31, 0xe7, 0x47, 0x22, 0x26, 0x34, 0x70, 0x94, 0x0e, 0xd6, 0xc0, 0xa2, + 0x60, 0x27, 0x98, 0x76, 0x11, 0xa6, 0x2c, 0xd4, 0xcb, 0xa9, 0xcd, 0x01, 0x59, 0xeb, 0x30, 0xed, + 0xc0, 0x16, 0x58, 0x4e, 0xa4, 0xc2, 0x0d, 0x59, 0x42, 0x85, 0x3e, 0x97, 0x25, 0x3f, 0xb9, 0xbc, + 0xae, 0x95, 0x7e, 0x5d, 0xd7, 0xd6, 0x64, 0x3a, 0x47, 0x27, 0x16, 0x61, 0x76, 0xe8, 0x8a, 0x63, + 0xeb, 0x35, 0x15, 0xce, 0x92, 0xf4, 0x34, 0x33, 0x0b, 0x7c, 0x05, 0x96, 0x12, 0x2e, 0x62, 0x34, + 0x8e, 0xb8, 0x73, 0x9b, 0x88, 0xc5, 0xcc, 0x22, 0x13, 0x5e, 0x3e, 0xfb, 0x3c, 0xea, 0x37, 0xd4, + 0x7f, 0xfe, 0x32, 0xea, 0x37, 0x1e, 0x2b, 0xfc, 0x67, 0x93, 0x05, 0xe4, 0x30, 0xd4, 0xd7, 0xc0, + 0xc3, 0x5c, 0xe9, 0x60, 0x1e, 0x31, 0xca, 0x71, 0xfd, 0x7b, 0x19, 0xac, 0x76, 0x78, 0x70, 0x10, + 0x63, 0x57, 0xe0, 0xa6, 0xf4, 0x41, 0x0b, 0x54, 0x5c, 0x14, 0x12, 0x3a, 0x93, 0x98, 0x94, 0xc1, + 0x2a, 0xa8, 0xe4, 0x51, 0xc9, 0x02, 0xea, 0xe0, 0x2e, 0xa6, 0xae, 0xd7, 0xc3, 0x28, 0xe3, 0xb3, + 0xe0, 0x8c, 0x4b, 0xf8, 0x16, 0xac, 0x46, 0x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1e, 0xb7, + 0xd5, 0x1a, 0x4e, 0xf7, 0x5f, 0xe4, 0x56, 0x21, 0xce, 0x23, 0xcc, 0xbd, 0xf9, 0xec, 0x22, 0x7d, + 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xd3, 0x67, 0x07, 0xd0, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // PlaceBid places a bid to buy a token off an auction + PlaceBid(ctx context.Context, in *MsgPlaceBid, opts ...grpc.CallOption) (*MsgPlaceBidResponse, error) + // CreateAuction creates a new auction + CreateAuction(ctx context.Context, in *MsgCreateAuction, opts ...grpc.CallOption) (*MsgCreateAuctionResponse, error) + // CreateAuction updates an existing auction + UpdateAuction(ctx context.Context, in *MsgUpdateAuction, opts ...grpc.CallOption) (*MsgUpdateAuctionResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) PlaceBid(ctx context.Context, in *MsgPlaceBid, opts ...grpc.CallOption) (*MsgPlaceBidResponse, error) { + out := new(MsgPlaceBidResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Msg/PlaceBid", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreateAuction(ctx context.Context, in *MsgCreateAuction, opts ...grpc.CallOption) (*MsgCreateAuctionResponse, error) { + out := new(MsgCreateAuctionResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Msg/CreateAuction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateAuction(ctx context.Context, in *MsgUpdateAuction, opts ...grpc.CallOption) (*MsgUpdateAuctionResponse, error) { + out := new(MsgUpdateAuctionResponse) + err := c.cc.Invoke(ctx, "/stride.auction.Msg/UpdateAuction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // PlaceBid places a bid to buy a token off an auction + PlaceBid(context.Context, *MsgPlaceBid) (*MsgPlaceBidResponse, error) + // CreateAuction creates a new auction + CreateAuction(context.Context, *MsgCreateAuction) (*MsgCreateAuctionResponse, error) + // CreateAuction updates an existing auction + UpdateAuction(context.Context, *MsgUpdateAuction) (*MsgUpdateAuctionResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) PlaceBid(ctx context.Context, req *MsgPlaceBid) (*MsgPlaceBidResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PlaceBid not implemented") +} +func (*UnimplementedMsgServer) CreateAuction(ctx context.Context, req *MsgCreateAuction) (*MsgCreateAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateAuction not implemented") +} +func (*UnimplementedMsgServer) UpdateAuction(ctx context.Context, req *MsgUpdateAuction) (*MsgUpdateAuctionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateAuction not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_PlaceBid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPlaceBid) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PlaceBid(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Msg/PlaceBid", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PlaceBid(ctx, req.(*MsgPlaceBid)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreateAuction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateAuction) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateAuction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Msg/CreateAuction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateAuction(ctx, req.(*MsgCreateAuction)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateAuction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateAuction) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateAuction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.auction.Msg/UpdateAuction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateAuction(ctx, req.(*MsgUpdateAuction)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "stride.auction.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PlaceBid", + Handler: _Msg_PlaceBid_Handler, + }, + { + MethodName: "CreateAuction", + Handler: _Msg_CreateAuction_Handler, + }, + { + MethodName: "UpdateAuction", + Handler: _Msg_UpdateAuction_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "stride/auction/tx.proto", +} + +func (m *MsgPlaceBid) 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 *MsgPlaceBid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.UstrdAmount.Size() + i -= size + if _, err := m.UstrdAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.UtokenAmount.Size() + i -= size + if _, err := m.UtokenAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.TokenDenom) > 0 { + i -= len(m.TokenDenom) + copy(dAtA[i:], m.TokenDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintTx(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPlaceBidResponse) 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 *MsgPlaceBidResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceBidResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateAuction) 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 *MsgCreateAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MinBidAmount.Size() + i -= size + if _, err := m.MinBidAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.PriceMultiplier.Size() + i -= size + if _, err := m.PriceMultiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateAuctionResponse) 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 *MsgCreateAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateAuction) 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 *MsgUpdateAuction) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MinBidAmount.Size() + i -= size + if _, err := m.MinBidAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.PriceMultiplier.Size() + i -= size + if _, err := m.PriceMultiplier.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateAuctionResponse) 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 *MsgUpdateAuctionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAuctionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgPlaceBid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.UtokenAmount.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.UstrdAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgPlaceBidResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Enabled { + n += 2 + } + l = m.PriceMultiplier.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.MinBidAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgCreateAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateAuction) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Enabled { + n += 2 + } + l = m.PriceMultiplier.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.MinBidAmount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgPlaceBid) 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 ErrIntOverflowTx + } + 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: MsgPlaceBid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceBid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bidder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UtokenAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UtokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UstrdAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UstrdAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPlaceBidResponse) 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 ErrIntOverflowTx + } + 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: MsgPlaceBidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceBidResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateAuction) 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 ErrIntOverflowTx + } + 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: MsgCreateAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinBidAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateAuctionResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateAuction) 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 ErrIntOverflowTx + } + 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: MsgUpdateAuction: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAuction: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinBidAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateAuctionResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateAuctionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 0ee04785f888a92faee08585c08ea6ef074050a1 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 15:07:21 +0200 Subject: [PATCH 011/115] icqoracle: register codec for msgs --- x/icqoracle/keeper/query.go | 2 ++ x/icqoracle/types/codec.go | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index 395e1efc69..60f57db7cf 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -43,6 +43,8 @@ func (k Keeper) TokenPrices(goCtx context.Context, req *types.QueryTokenPricesRe ctx := sdk.UnwrapSDKContext(goCtx) + // TODO impl paging + prices := k.GetAllTokenPrices(ctx) return &types.QueryTokenPricesResponse{ diff --git a/x/icqoracle/types/codec.go b/x/icqoracle/types/codec.go index 706c317048..d2ad84ca6c 100644 --- a/x/icqoracle/types/codec.go +++ b/x/icqoracle/types/codec.go @@ -11,16 +11,17 @@ import ( ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - // TODO [msgserver]: register legacy amino for each msg - // legacy.RegisterAminoMsg(cdc, &MsgSomeMessage{}, "icqoracle/MsgSomeMessage") - _ = legacy.Cdc // remove + legacy.RegisterAminoMsg(cdc, &MsgAddTokenPrice{}, "icqoracle/MsgAddTokenPrice") + legacy.RegisterAminoMsg(cdc, &MsgRemoveTokenPrice{}, "icqoracle/MsgRemoveTokenPrice") } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // TODO [msgserver]: add implement sdk.Msg interface for message types - // registry.RegisterImplementations((*sdk.Msg)(nil), ...) - // msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) - _ = msgservice.E_Service // remove + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgAddTokenPrice{}, + &MsgRemoveTokenPrice{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } var ( From 1cdcd14dbfbfaad6d355341f5c42b20493c44a0a Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 15:34:22 +0200 Subject: [PATCH 012/115] fix update auction to use price multiplier from msg --- x/auction/keeper/msg_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 18987a28a8..cf932a0e34 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -71,7 +71,7 @@ func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuc auction.Enabled = msg.Enabled auction.MinBidAmount = msg.MinBidAmount - auction.PriceMultiplier = auction.PriceMultiplier + auction.PriceMultiplier = msg.PriceMultiplier err = ms.Keeper.SetAuction(ctx, auction) if err != nil { From c0eb65913067ae841f22e62a582de72d1b25aa41 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 15:34:47 +0200 Subject: [PATCH 013/115] fix error message to include token denom --- x/auction/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 1ca64083d4..b18f89e5b4 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -123,7 +123,7 @@ func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { // Get auction auction, err := k.GetAuction(ctx, bid.TokenDenom) if err != nil { - return fmt.Errorf("cannot get auction for denom='%s': %w", err) + return fmt.Errorf("cannot get auction for denom='%s': %w", bid.TokenDenom, err) } // Get token amount being auctioned off From 6a3f9d82681ff7b538449329f63729ba1175f533 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 15:35:10 +0200 Subject: [PATCH 014/115] inline stats into auction --- proto/stride/auction/auction.proto | 10 +- proto/stride/auction/query.proto | 31 - x/auction/keeper/keeper.go | 34 - x/auction/keeper/query.go | 35 - x/auction/types/auction.pb.go | 272 ++----- x/auction/types/keys.go | 5 - x/auction/types/query.pb.go | 1192 ++++------------------------ x/auction/types/query.pb.gw.go | 184 ----- 8 files changed, 220 insertions(+), 1543 deletions(-) diff --git a/proto/stride/auction/auction.proto b/proto/stride/auction/auction.proto index d1e34a806b..f8812a6cbb 100644 --- a/proto/stride/auction/auction.proto +++ b/proto/stride/auction/auction.proto @@ -26,21 +26,15 @@ message Auction { (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; -} - -// Stats tracks burning metrics -message Stats { - // Token denom being tracked - string token_denom = 1; // Total amount of STRD burned - string total_strd_burned = 2 [ + string total_strd_burned = 5 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // Total amount of tokens sold - string total_tokens_sold = 3 [ + string total_tokens_sold = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; diff --git a/proto/stride/auction/query.proto b/proto/stride/auction/query.proto index 388db4aab3..34242d4433 100644 --- a/proto/stride/auction/query.proto +++ b/proto/stride/auction/query.proto @@ -19,16 +19,6 @@ service Query { rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) { option (google.api.http).get = "/auction/v1beta1/auctions"; } - - // Stats queries the auction stats for a specific token - rpc Stats(QueryStatsRequest) returns (QueryStatsResponse) { - option (google.api.http).get = "/auction/v1beta1/stats/{denom}"; - } - - // AllStats queries the auction stats for a specific token - rpc AllStats(QueryAllStatsRequest) returns (QueryAllStatsResponse) { - option (google.api.http).get = "/auction/v1beta1/stats"; - } } // QueryAuctionRequest is the request type for the Query/Auction RPC @@ -53,24 +43,3 @@ message QueryAuctionsResponse { repeated Auction auctions = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } - -// QueryStatsRequest is the request type for the Query/TokenStats RPC -// method -message QueryStatsRequest { string denom = 1; } - -// QueryStatsResponse is the response type for the Query/TokenStats RPC -// method -message QueryStatsResponse { Stats stats = 1 [ (gogoproto.nullable) = false ]; } - -// QueryAllStatsRequest is the request type for the -// Query/Auctions RPC method -message QueryAllStatsRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -// QueryAllStatsResponse is the response type for the -// Query/Auctions RPC method -message QueryAllStatsResponse { - repeated Stats all_stats = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} \ No newline at end of file diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index b18f89e5b4..d45e592b25 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -84,40 +84,6 @@ func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { return auctions } -// GetStats retrieves stats info for an auction -func (k Keeper) GetStats(ctx sdk.Context, denom string) (types.Stats, error) { - store := ctx.KVStore(k.storeKey) - key := types.StatsKey(denom) - - bz := store.Get(key) - if bz == nil { - return types.Stats{}, fmt.Errorf("Stats not found for auction denom='%s'", denom) - } - - var stats types.Stats - if err := k.cdc.Unmarshal(bz, &stats); err != nil { - return types.Stats{}, err - } - - return stats, nil -} - -// GetAllStats retrieves all stored auctions stats -func (k Keeper) GetAllStats(ctx sdk.Context) []types.Stats { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyStatsPrefix)) - defer iterator.Close() - - allStats := []types.Stats{} - for ; iterator.Valid(); iterator.Next() { - var auctionStats types.Stats - k.cdc.MustUnmarshal(iterator.Value(), &auctionStats) - allStats = append(allStats, auctionStats) - } - - return allStats -} - // SetAuction stores auction info for a token func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { // Get auction diff --git a/x/auction/keeper/query.go b/x/auction/keeper/query.go index c561822422..ab5c0f95b3 100644 --- a/x/auction/keeper/query.go +++ b/x/auction/keeper/query.go @@ -47,38 +47,3 @@ func (k Keeper) Auctions(goCtx context.Context, req *types.QueryAuctionsRequest) Auctions: auctions, }, nil } - -// Stats queries the auction stats for a specific auction -func (k Keeper) Stats(goCtx context.Context, req *types.QueryStatsRequest) (*types.QueryStatsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - stats, err := k.GetStats(ctx, req.Denom) - if err != nil { - return nil, status.Error(codes.NotFound, err.Error()) - } - - return &types.QueryStatsResponse{ - Stats: stats, - }, nil -} - -// AllStats queries the auction stats for all auctions -func (k Keeper) AllStats(goCtx context.Context, req *types.QueryAllStatsRequest) (*types.QueryAllStatsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - allStats := k.GetAllStats(ctx) - - // TODO impl paging - - return &types.QueryAllStatsResponse{ - AllStats: allStats, - }, nil -} diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index ee22ecfea8..53924a7a10 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -70,6 +70,10 @@ type Auction struct { PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + // Total amount of STRD burned + TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` + // Total amount of tokens sold + TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` } func (m *Auction) Reset() { *m = Auction{} } @@ -119,90 +123,37 @@ func (m *Auction) GetEnabled() bool { return false } -// Stats tracks burning metrics -type Stats struct { - // Token denom being tracked - TokenDenom string `protobuf:"bytes,1,opt,name=token_denom,json=tokenDenom,proto3" json:"token_denom,omitempty"` - // Total amount of STRD burned - TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` - // Total amount of tokens sold - TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` -} - -func (m *Stats) Reset() { *m = Stats{} } -func (m *Stats) String() string { return proto.CompactTextString(m) } -func (*Stats) ProtoMessage() {} -func (*Stats) Descriptor() ([]byte, []int) { - return fileDescriptor_739480caccbf7be9, []int{2} -} -func (m *Stats) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Stats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Stats.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 *Stats) XXX_Merge(src proto.Message) { - xxx_messageInfo_Stats.Merge(m, src) -} -func (m *Stats) XXX_Size() int { - return m.Size() -} -func (m *Stats) XXX_DiscardUnknown() { - xxx_messageInfo_Stats.DiscardUnknown(m) -} - -var xxx_messageInfo_Stats proto.InternalMessageInfo - -func (m *Stats) GetTokenDenom() string { - if m != nil { - return m.TokenDenom - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "stride.auction.Params") proto.RegisterType((*Auction)(nil), "stride.auction.Auction") - proto.RegisterType((*Stats)(nil), "stride.auction.Stats") } func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_739480caccbf7be9) } var fileDescriptor_739480caccbf7be9 = []byte{ - // 372 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbb, 0x0e, 0xd3, 0x30, - 0x14, 0x86, 0x63, 0xa0, 0x17, 0x0c, 0x6a, 0x21, 0x2a, 0x52, 0xc4, 0x25, 0xad, 0xca, 0xd2, 0x85, - 0x44, 0x5c, 0x5e, 0xa0, 0xa1, 0x4b, 0x45, 0x41, 0x28, 0x61, 0x62, 0x89, 0x9c, 0xd8, 0x4a, 0xad, - 0xc6, 0x76, 0x64, 0x9f, 0x20, 0xfa, 0x16, 0x3c, 0x11, 0x73, 0x27, 0xd4, 0x11, 0x31, 0x54, 0xa8, - 0x7d, 0x11, 0x54, 0x27, 0x2d, 0x48, 0x0c, 0x30, 0xd9, 0xe7, 0xf2, 0xfd, 0xd6, 0xef, 0x73, 0xf0, - 0x63, 0x03, 0x9a, 0x53, 0x16, 0x92, 0x3a, 0x07, 0xae, 0xe4, 0xe5, 0x0c, 0x2a, 0xad, 0x40, 0xb9, - 0x83, 0xa6, 0x1a, 0xb4, 0xd9, 0x87, 0xa3, 0x42, 0x15, 0xca, 0x96, 0xc2, 0xf3, 0xad, 0xe9, 0x9a, - 0xf6, 0x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, 0x0f, 0x16, 0x4b, 0x54, 0x49, 0xa3, 0x37, 0xbb, - 0xa3, 0x8f, 0xf6, 0x47, 0x1f, 0xfd, 0x3c, 0xfa, 0xe8, 0xcb, 0xc9, 0x77, 0xf6, 0x27, 0xdf, 0xf9, - 0x7e, 0xf2, 0x9d, 0x8f, 0xcf, 0x0b, 0x0e, 0xeb, 0x3a, 0x0b, 0x72, 0x25, 0xc2, 0xc4, 0x8e, 0xf9, - 0xd9, 0x8a, 0x64, 0x26, 0x6c, 0x17, 0xe2, 0xd3, 0x8b, 0x57, 0xe1, 0xe7, 0xeb, 0x5a, 0xc0, 0xb6, - 0x62, 0x26, 0xeb, 0xda, 0x79, 0xbf, 0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, 0x76, 0x15, 0xb1, 0x5e, - 0x35, 0x02, 0x00, 0x00, + // 349 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xcb, 0x4e, 0xf2, 0x40, + 0x18, 0x86, 0x5b, 0xfe, 0x9f, 0x83, 0x13, 0x03, 0xda, 0x60, 0xd2, 0x78, 0x28, 0x04, 0x37, 0x6c, + 0x6c, 0xe3, 0xe1, 0x06, 0xa8, 0x6e, 0x88, 0x68, 0x4c, 0x71, 0xe5, 0xa6, 0x99, 0x76, 0x26, 0x65, + 0x42, 0x67, 0xa6, 0x99, 0x99, 0x1a, 0xb9, 0x0b, 0x2f, 0x8b, 0x25, 0x4b, 0xe3, 0x82, 0x18, 0xf0, + 0x42, 0x0c, 0x53, 0xc0, 0x85, 0x1b, 0x56, 0x33, 0xdf, 0xf7, 0xbd, 0xcf, 0xb3, 0x79, 0xc1, 0xa9, + 0x54, 0x82, 0x20, 0xec, 0xc1, 0x3c, 0x56, 0x84, 0xb3, 0xcd, 0xeb, 0x66, 0x82, 0x2b, 0x6e, 0xd5, + 0x8b, 0xab, 0xbb, 0xde, 0x1e, 0x37, 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e6, 0x6c, 0xe1, 0x98, + 0x5f, 0x0b, 0xc7, 0x7c, 0x5f, 0x3a, 0xc6, 0x6c, 0xe9, 0x18, 0x1f, 0x4b, 0xc7, 0x78, 0xb9, 0x4c, + 0x88, 0x1a, 0xe5, 0x91, 0x1b, 0x73, 0xea, 0x0d, 0x75, 0x77, 0x17, 0x03, 0x18, 0x49, 0x6f, 0xdd, + 0xf2, 0xeb, 0xd5, 0x8d, 0xf7, 0xb6, 0xed, 0x5a, 0x4d, 0x32, 0x2c, 0xa3, 0x8a, 0x2e, 0xf1, 0xfa, + 0x27, 0x00, 0x00, 0xff, 0xff, 0x89, 0x6f, 0xef, 0x26, 0x0a, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -248,6 +199,26 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TotalTokensSold.Size() + i -= size + if _, err := m.TotalTokensSold.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.TotalStrdBurned.Size() + i -= size + if _, err := m.TotalStrdBurned.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuction(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a { size := m.MinBidAmount.Size() i -= size @@ -288,56 +259,6 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Stats) 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 *Stats) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Stats) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.TotalTokensSold.Size() - i -= size - if _, err := m.TotalTokensSold.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.TotalStrdBurned.Size() - i -= size - if _, err := m.TotalStrdBurned.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintAuction(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.TokenDenom) > 0 { - i -= len(m.TokenDenom) - copy(dAtA[i:], m.TokenDenom) - i = encodeVarintAuction(dAtA, i, uint64(len(m.TokenDenom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintAuction(dAtA []byte, offset int, v uint64) int { offset -= sovAuction(v) base := offset @@ -375,19 +296,6 @@ func (m *Auction) Size() (n int) { n += 1 + l + sovAuction(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovAuction(uint64(l)) - return n -} - -func (m *Stats) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.TokenDenom) - if l > 0 { - n += 1 + l + sovAuction(uint64(l)) - } l = m.TotalStrdBurned.Size() n += 1 + l + sovAuction(uint64(l)) l = m.TotalTokensSold.Size() @@ -600,89 +508,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAuction(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAuction - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Stats) 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 ErrIntOverflowAuction - } - 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: Stats: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Stats: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuction - } - 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 ErrInvalidLengthAuction - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAuction - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TokenDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalStrdBurned", wireType) } @@ -716,7 +542,7 @@ func (m *Stats) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalTokensSold", wireType) } diff --git a/x/auction/types/keys.go b/x/auction/types/keys.go index e8ed84e6ba..30f31af010 100644 --- a/x/auction/types/keys.go +++ b/x/auction/types/keys.go @@ -13,13 +13,8 @@ const ( ParamsPrefix = "params" KeyAuctionPrefix = "auction" - KeyStatsPrefix = "stats" ) func AuctionKey(denom string) []byte { return []byte(fmt.Sprintf("%s%s", KeyAuctionPrefix, denom)) } - -func StatsKey(denom string) []byte { - return []byte(fmt.Sprintf("%s%s", KeyStatsPrefix, denom)) -} diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index ef9a52caf7..26f13881d5 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -222,248 +222,44 @@ func (m *QueryAuctionsResponse) GetPagination() *query.PageResponse { return nil } -// QueryStatsRequest is the request type for the Query/TokenStats RPC -// method -type QueryStatsRequest struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` -} - -func (m *QueryStatsRequest) Reset() { *m = QueryStatsRequest{} } -func (m *QueryStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryStatsRequest) ProtoMessage() {} -func (*QueryStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8113674a9412675c, []int{4} -} -func (m *QueryStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryStatsRequest.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 *QueryStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryStatsRequest.Merge(m, src) -} -func (m *QueryStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryStatsRequest proto.InternalMessageInfo - -func (m *QueryStatsRequest) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -// QueryStatsResponse is the response type for the Query/TokenStats RPC -// method -type QueryStatsResponse struct { - Stats Stats `protobuf:"bytes,1,opt,name=stats,proto3" json:"stats"` -} - -func (m *QueryStatsResponse) Reset() { *m = QueryStatsResponse{} } -func (m *QueryStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryStatsResponse) ProtoMessage() {} -func (*QueryStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8113674a9412675c, []int{5} -} -func (m *QueryStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryStatsResponse.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 *QueryStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryStatsResponse.Merge(m, src) -} -func (m *QueryStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryStatsResponse proto.InternalMessageInfo - -func (m *QueryStatsResponse) GetStats() Stats { - if m != nil { - return m.Stats - } - return Stats{} -} - -// QueryAllStatsRequest is the request type for the -// Query/Auctions RPC method -type QueryAllStatsRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllStatsRequest) Reset() { *m = QueryAllStatsRequest{} } -func (m *QueryAllStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllStatsRequest) ProtoMessage() {} -func (*QueryAllStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8113674a9412675c, []int{6} -} -func (m *QueryAllStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllStatsRequest.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 *QueryAllStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllStatsRequest.Merge(m, src) -} -func (m *QueryAllStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAllStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllStatsRequest proto.InternalMessageInfo - -func (m *QueryAllStatsRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryAllStatsResponse is the response type for the -// Query/Auctions RPC method -type QueryAllStatsResponse struct { - AllStats []Stats `protobuf:"bytes,1,rep,name=all_stats,json=allStats,proto3" json:"all_stats"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllStatsResponse) Reset() { *m = QueryAllStatsResponse{} } -func (m *QueryAllStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllStatsResponse) ProtoMessage() {} -func (*QueryAllStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8113674a9412675c, []int{7} -} -func (m *QueryAllStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllStatsResponse.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 *QueryAllStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllStatsResponse.Merge(m, src) -} -func (m *QueryAllStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAllStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllStatsResponse proto.InternalMessageInfo - -func (m *QueryAllStatsResponse) GetAllStats() []Stats { - if m != nil { - return m.AllStats - } - return nil -} - -func (m *QueryAllStatsResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} - func init() { proto.RegisterType((*QueryAuctionRequest)(nil), "stride.auction.QueryAuctionRequest") proto.RegisterType((*QueryAuctionResponse)(nil), "stride.auction.QueryAuctionResponse") proto.RegisterType((*QueryAuctionsRequest)(nil), "stride.auction.QueryAuctionsRequest") proto.RegisterType((*QueryAuctionsResponse)(nil), "stride.auction.QueryAuctionsResponse") - proto.RegisterType((*QueryStatsRequest)(nil), "stride.auction.QueryStatsRequest") - proto.RegisterType((*QueryStatsResponse)(nil), "stride.auction.QueryStatsResponse") - proto.RegisterType((*QueryAllStatsRequest)(nil), "stride.auction.QueryAllStatsRequest") - proto.RegisterType((*QueryAllStatsResponse)(nil), "stride.auction.QueryAllStatsResponse") } func init() { proto.RegisterFile("stride/auction/query.proto", fileDescriptor_8113674a9412675c) } var fileDescriptor_8113674a9412675c = []byte{ - // 550 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xe3, 0x86, 0xd0, 0x74, 0x90, 0x90, 0x58, 0x52, 0x08, 0xa6, 0x32, 0xa9, 0x81, 0x52, - 0x40, 0x78, 0x95, 0x80, 0x04, 0x1c, 0xe9, 0x81, 0x1e, 0x40, 0x02, 0xd2, 0x1b, 0x07, 0xd0, 0x26, - 0x5d, 0x19, 0x4b, 0x8e, 0xd7, 0xcd, 0x6e, 0x02, 0x05, 0xc1, 0x81, 0x27, 0x40, 0xe2, 0x06, 0x2f, - 0xd4, 0x63, 0x25, 0x2e, 0x9c, 0x10, 0x4a, 0x78, 0x04, 0x1e, 0x00, 0x79, 0x77, 0xec, 0xc4, 0x26, - 0x7f, 0x2e, 0x3d, 0x25, 0xf6, 0x7e, 0x3b, 0xdf, 0xef, 0x9b, 0x9d, 0x35, 0xd8, 0x52, 0xf5, 0x83, - 0x7d, 0x4e, 0xd9, 0xa0, 0xab, 0x02, 0x11, 0xd1, 0x83, 0x01, 0xef, 0x1f, 0x7a, 0x71, 0x5f, 0x28, - 0x41, 0xce, 0x9a, 0x35, 0x0f, 0xd7, 0xec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23, 0xc7, 0xfa, 0x3d, 0x72, 0xac, 0x2f, 0x63, 0xa7, 0x74, 0x3c, 0x76, 0x4a, - 0x3f, 0xc7, 0x4e, 0xe9, 0x65, 0xd3, 0x0f, 0xd4, 0x9b, 0x41, 0xc7, 0xeb, 0x8a, 0x1e, 0xdd, 0xd3, - 0x56, 0x77, 0x9e, 0xb2, 0x8e, 0xa4, 0xf8, 0x49, 0x1e, 0xb6, 0xee, 0xd1, 0x77, 0x59, 0x51, 0x75, - 0x18, 0x73, 0xd9, 0x39, 0xad, 0xbf, 0x9b, 0x77, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x93, 0x01, - 0x5c, 0xa0, 0xe3, 0x05, 0x00, 0x00, + // 431 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x2e, 0x29, 0xca, + 0x4c, 0x49, 0xd5, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, + 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xe9, 0x41, 0xe5, 0xa4, 0x64, 0xd0, + 0xd4, 0x42, 0x69, 0x88, 0x6a, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4, 0x82, + 0x8a, 0xca, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, + 0xe5, 0x97, 0x24, 0x82, 0xb4, 0x14, 0x43, 0x65, 0xb5, 0x92, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, + 0x93, 0x12, 0x8b, 0x53, 0x21, 0x56, 0xeb, 0x97, 0x19, 0x26, 0xa5, 0x96, 0x24, 0x1a, 0xea, 0x17, + 0x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, 0x22, 0x88, 0x5d, 0x4a, 0x1a, 0x4d, 0x97, 0x9f, 0x4c, + 0x66, 0x52, 0x12, 0x52, 0x80, 0xa7, 0x2d, 0x58, 0x32, 0x80, 0xf1, 0xab, 0xc1, 0xf1, 0x5a, 0x2b, + 0x54, 0xc5, 0xc5, 0x01, 0x0b, 0x21, 0x21, 0xbc, 0x66, 0xc3, 0x62, 0x48, 0x4a, 0x95, 0x80, 0x2a, + 0xa8, 0x13, 0x14, 0xc1, 0x4e, 0x90, 0x16, 0x92, 0xc4, 0xe5, 0x84, 0x62, 0x27, 0xef, 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, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, + 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x06, 0xdb, 0xa6, 0xeb, 0x93, 0x98, 0x54, 0xac, 0x0f, 0xcd, 0x30, + 0x65, 0x46, 0x26, 0xfa, 0x15, 0x70, 0x73, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xa9, + 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xf9, 0x43, 0x5b, 0x81, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -482,10 +278,6 @@ type QueryClient interface { Auction(ctx context.Context, in *QueryAuctionRequest, opts ...grpc.CallOption) (*QueryAuctionResponse, error) // Auctions queries the auction info for a specific token Auctions(ctx context.Context, in *QueryAuctionsRequest, opts ...grpc.CallOption) (*QueryAuctionsResponse, error) - // Stats queries the auction stats for a specific token - Stats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) - // AllStats queries the auction stats for a specific token - AllStats(ctx context.Context, in *QueryAllStatsRequest, opts ...grpc.CallOption) (*QueryAllStatsResponse, error) } type queryClient struct { @@ -514,34 +306,12 @@ func (c *queryClient) Auctions(ctx context.Context, in *QueryAuctionsRequest, op return out, nil } -func (c *queryClient) Stats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) { - out := new(QueryStatsResponse) - err := c.cc.Invoke(ctx, "/stride.auction.Query/Stats", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AllStats(ctx context.Context, in *QueryAllStatsRequest, opts ...grpc.CallOption) (*QueryAllStatsResponse, error) { - out := new(QueryAllStatsResponse) - err := c.cc.Invoke(ctx, "/stride.auction.Query/AllStats", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Auction queries the auction info for a specific token Auction(context.Context, *QueryAuctionRequest) (*QueryAuctionResponse, error) // Auctions queries the auction info for a specific token Auctions(context.Context, *QueryAuctionsRequest) (*QueryAuctionsResponse, error) - // Stats queries the auction stats for a specific token - Stats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) - // AllStats queries the auction stats for a specific token - AllStats(context.Context, *QueryAllStatsRequest) (*QueryAllStatsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -554,12 +324,6 @@ func (*UnimplementedQueryServer) Auction(ctx context.Context, req *QueryAuctionR func (*UnimplementedQueryServer) Auctions(ctx context.Context, req *QueryAuctionsRequest) (*QueryAuctionsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Auctions not implemented") } -func (*UnimplementedQueryServer) Stats(ctx context.Context, req *QueryStatsRequest) (*QueryStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Stats not implemented") -} -func (*UnimplementedQueryServer) AllStats(ctx context.Context, req *QueryAllStatsRequest) (*QueryAllStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AllStats not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -601,42 +365,6 @@ func _Query_Auctions_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } -func _Query_Stats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryStatsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Stats(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/stride.auction.Query/Stats", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Stats(ctx, req.(*QueryStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_AllStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllStatsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AllStats(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/stride.auction.Query/AllStats", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AllStats(ctx, req.(*QueryAllStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "stride.auction.Query", HandlerType: (*QueryServer)(nil), @@ -649,14 +377,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Auctions", Handler: _Query_Auctions_Handler, }, - { - MethodName: "Stats", - Handler: _Query_Stats_Handler, - }, - { - MethodName: "AllStats", - Handler: _Query_AllStats_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "stride/auction/query.proto", @@ -743,720 +463,146 @@ func (m *QueryAuctionsRequest) MarshalTo(dAtA []byte) (int, error) { func (m *QueryAuctionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAuctionsResponse) 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 *QueryAuctionsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAuctionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Auctions) > 0 { - for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryStatsRequest) 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 *QueryStatsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryStatsResponse) 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 *QueryStatsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Stats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryAllStatsRequest) 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 *QueryAllStatsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAllStatsResponse) 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 *QueryAllStatsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.AllStats) > 0 { - for iNdEx := len(m.AllStats) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AllStats[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryAuctionRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAuctionResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Auction.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAuctionsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAuctionsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Auctions) > 0 { - for _, e := range m.Auctions { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryStatsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryStatsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Stats.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAllStatsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAllStatsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AllStats) > 0 { - for _, e := range m.AllStats { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryAuctionRequest) 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: QueryAuctionRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAuctionRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) - 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 *QueryAuctionResponse) 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: QueryAuctionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Auction", 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 := m.Auction.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 (m *QueryAuctionsRequest) 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: QueryAuctionsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAuctionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - iNdEx += skippy + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa } + return len(dAtA) - i, nil +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *QueryAuctionsResponse) 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 nil + return dAtA[:n], nil } -func (m *QueryAuctionsResponse) 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 + +func (m *QueryAuctionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAuctionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAuctionsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAuctionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Auctions", 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 - } - m.Auctions = append(m.Auctions, Auction{}) - if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 + i-- + dAtA[i] = 0x12 + } + if len(m.Auctions) > 0 { + for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Auctions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 + i-- + dAtA[i] = 0xa } } + return len(dAtA) - i, nil +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return nil + dAtA[offset] = uint8(v) + return base +} +func (m *QueryAuctionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Auction.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAuctionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAuctionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Auctions) > 0 { + for _, e := range m.Auctions { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryStatsRequest) Unmarshal(dAtA []byte) error { + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryAuctionRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1479,10 +625,10 @@ func (m *QueryStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAuctionRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAuctionRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1538,7 +684,7 @@ func (m *QueryStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAuctionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1561,15 +707,15 @@ func (m *QueryStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAuctionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAuctionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Auction", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1596,7 +742,7 @@ func (m *QueryStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Stats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Auction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1621,7 +767,7 @@ func (m *QueryStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAuctionsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1644,10 +790,10 @@ func (m *QueryAllStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAuctionsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAuctionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1707,7 +853,7 @@ func (m *QueryAllStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAuctionsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1730,15 +876,15 @@ func (m *QueryAllStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAuctionsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAuctionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AllStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Auctions", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1765,8 +911,8 @@ func (m *QueryAllStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AllStats = append(m.AllStats, Stats{}) - if err := m.AllStats[len(m.AllStats)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Auctions = append(m.Auctions, Auction{}) + if err := m.Auctions[len(m.Auctions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/auction/types/query.pb.gw.go b/x/auction/types/query.pb.gw.go index de7b6bfe26..f29fad68a3 100644 --- a/x/auction/types/query.pb.gw.go +++ b/x/auction/types/query.pb.gw.go @@ -123,96 +123,6 @@ func local_request_Query_Auctions_0(ctx context.Context, marshaler runtime.Marsh } -func request_Query_Stats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryStatsRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") - } - - protoReq.Denom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) - } - - msg, err := client.Stats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Stats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryStatsRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["denom"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") - } - - protoReq.Denom, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) - } - - msg, err := server.Stats(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_AllStats_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_AllStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllStatsRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllStats_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.AllStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AllStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllStatsRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllStats_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.AllStats(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -265,52 +175,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_Stats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Stats_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Stats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AllStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_AllStats_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AllStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -392,46 +256,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_Stats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Stats_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Stats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AllStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_AllStats_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AllStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -439,18 +263,10 @@ var ( pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0, 1, 0, 4, 1, 5, 2}, []string{"auction", "v1beta1", "denom"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auction", "v1beta1", "auctions"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Stats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"auction", "v1beta1", "stats", "denom"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_AllStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auction", "v1beta1", "stats"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Auction_0 = runtime.ForwardResponseMessage forward_Query_Auctions_0 = runtime.ForwardResponseMessage - - forward_Query_Stats_0 = runtime.ForwardResponseMessage - - forward_Query_AllStats_0 = runtime.ForwardResponseMessage ) From 3b16bda2da7ce27428386b4dce8af5df95686173 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 15:35:23 +0200 Subject: [PATCH 015/115] implement cli commands --- x/auction/client/cli/query.go | 54 +++++------------ x/auction/client/cli/tx.go | 111 +++++++++++++++++++++++++++------- 2 files changed, 102 insertions(+), 63 deletions(-) diff --git a/x/auction/client/cli/query.go b/x/auction/client/cli/query.go index c419015dd7..ee50c621ba 100644 --- a/x/auction/client/cli/query.go +++ b/x/auction/client/cli/query.go @@ -22,34 +22,29 @@ func GetQueryCmd() *cobra.Command { } cmd.AddCommand( - CmdQueryTokenPrice(), - CmdQueryTokenPrices(), - CmdQueryParams(), + CmdQueryAuction(), + CmdQueryAuctions(), ) return cmd } -func CmdQueryTokenPrice() *cobra.Command { +func CmdQueryAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "token-price [base-denom] [quote-denom]", - Short: "Query the current price for a specific token", - Args: cobra.ExactArgs(2), + Use: "auction [denom]", + Short: "Query the auction info for a specific token", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - baseDenom := args[0] - quoteDenom := args[1] - clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryTokenPriceRequest{ - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, + req := &types.QueryAuctionRequest{ + Denom: args[0], } - res, err := queryClient.TokenPrice(context.Background(), req) + res, err := queryClient.Auction(context.Background(), req) if err != nil { return err } @@ -59,10 +54,10 @@ func CmdQueryTokenPrice() *cobra.Command { return cmd } -func CmdQueryTokenPrices() *cobra.Command { +func CmdQueryAuctions() *cobra.Command { cmd := &cobra.Command{ - Use: "token-prices", - Short: "Query all token prices", + Use: "auctions", + Short: "Query all auctions", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -70,30 +65,9 @@ func CmdQueryTokenPrices() *cobra.Command { return err } queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryTokenPricesRequest{} - res, err := queryClient.TokenPrices(context.Background(), req) - if err != nil { - return err - } - return clientCtx.PrintProto(res) - }, - } - return cmd -} -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "Get the parameters", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryParamsRequest{} - res, err := queryClient.Params(context.Background(), req) + req := &types.QueryAuctionsRequest{} + res, err := queryClient.Auctions(context.Background(), req) if err != nil { return err } diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index ea63567bdc..92a745a49b 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -2,11 +2,13 @@ package cli import ( "fmt" + "strconv" "strings" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cobra" @@ -24,22 +26,23 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand( - CmdAddTokenPrice(), - CmdRemoveTokenPrice(), + CmdPlaceBid(), + CmdCreateAuction(), + CmdUpdateAuction(), ) return cmd } -func CmdAddTokenPrice() *cobra.Command { +func CmdPlaceBid() *cobra.Command { cmd := &cobra.Command{ - Use: "add-token-price [base-denom] [quote-denom] [osmosis-pool-id] [osmosis-base-denom] [osmosis-quote-denom]", - Short: "Add a token to price tracking", + Use: "place-bid [utokenAmount] [ustrdAmount]", + Short: "Place a bid on an auction", Long: strings.TrimSpace( - fmt.Sprintf(`Add a token to price tracking. + fmt.Sprintf(`Place a bid on an auction for a specific token. Example: - $ %[1]s tx %[2]s add-token-price uosmo uatom 123 uosmo ibc/... --from admin + $ %[1]s tx %[2]s place-bid 123ibc/DEADBEEF 1000000 --from mykey `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(2), @@ -49,13 +52,21 @@ Example: return err } - msg := types.NewMsgAddTokenPrice( + coin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return fmt.Errorf("cannot parse token amount and denom from '%s': %w", args[0], err) + } + + ustrdAmount, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return fmt.Errorf("cannot parse ustrdAmount as uint64 from '%s': %w", args[2], err) + } + + msg := types.NewMsgPlaceBid( clientCtx.GetFromAddress().String(), - args[0], - args[1], - args[2], - args[3], - args[4], + coin.Denom, + coin.Amount.Uint64(), + ustrdAmount, ) if err := msg.ValidateBasic(); err != nil { @@ -71,29 +82,83 @@ Example: return cmd } -func CmdRemoveTokenPrice() *cobra.Command { +func CmdCreateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "remove-token-price [base-denom] [quote-denom] [osmosis-pool-id]", - Short: "Remove a token from price tracking", + Use: "create-auction [denom] [enabled] [price-multiplier] [min-bid-amount]", + Short: "Create a new auction", Long: strings.TrimSpace( - fmt.Sprintf(`Remove a token from price tracking. + fmt.Sprintf(`Create a new auction for a specific token. Example: - $ %[1]s tx %[2]s remove-token-price uatom uosmo 123 --from admin + $ %[1]s tx %[2]s create-auction ibc/DEADBEEF true 0.95 1000000 --from admin `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - msg := types.NewMsgRemoveTokenPrice( + enabled := args[1] == "true" + + minBidAmount, err := strconv.ParseUint(args[3], 10, 64) + if err != nil { + return fmt.Errorf("cannot parse minBidAmount as uint64 from '%s': %w", args[3], err) + } + + msg := types.NewMsgCreateAuction( + clientCtx.GetFromAddress().String(), + args[0], // denom + enabled, // enabled + args[2], // price multiplier + minBidAmount, // min bid amount + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdUpdateAuction() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-auction [denom] [enabled] [price-multiplier] [min-bid-amount]", + Short: "Update an existing auction", + Long: strings.TrimSpace( + fmt.Sprintf(`Update an existing auction's parameters. + +Example: + $ %[1]s tx %[2]s update-auction ibc/DEADBEEF true 0.97 500000 --from admin +`, version.AppName, types.ModuleName), + ), + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + enabled := args[1] == "true" + + minBidAmount, err := strconv.ParseUint(args[3], 10, 64) + if err != nil { + return fmt.Errorf("cannot parse minBidAmount as uint64 from '%s': %w", args[3], err) + } + + msg := types.NewMsgUpdateAuction( clientCtx.GetFromAddress().String(), - args[0], - args[1], - args[2], + args[0], // denom + enabled, // enabled + args[2], // price multiplier + minBidAmount, // min bid amount ) if err := msg.ValidateBasic(); err != nil { From c2863a3b1bd6677a0a2775867cf2f59bc3777d60 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 15:43:53 +0200 Subject: [PATCH 016/115] add beneficiary to auction --- proto/stride/auction/auction.proto | 7 +- proto/stride/auction/tx.proto | 4 + x/auction/client/cli/tx.go | 7 +- x/auction/keeper/msg_server.go | 2 + x/auction/types/auction.pb.go | 111 +++++++++++++----- x/auction/types/msgs.go | 10 ++ x/auction/types/tx.pb.go | 178 +++++++++++++++++++++++------ 7 files changed, 250 insertions(+), 69 deletions(-) diff --git a/proto/stride/auction/auction.proto b/proto/stride/auction/auction.proto index f8812a6cbb..f0aacc0b91 100644 --- a/proto/stride/auction/auction.proto +++ b/proto/stride/auction/auction.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package stride.auction; import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; @@ -27,14 +28,16 @@ message Auction { (gogoproto.nullable) = false ]; + string beneficiary = 5 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // Total amount of STRD burned - string total_strd_burned = 5 [ + string total_strd_burned = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // Total amount of tokens sold - string total_tokens_sold = 6 [ + string total_tokens_sold = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; diff --git a/proto/stride/auction/tx.proto b/proto/stride/auction/tx.proto index 33a1cb99f9..156d13dc04 100644 --- a/proto/stride/auction/tx.proto +++ b/proto/stride/auction/tx.proto @@ -76,6 +76,8 @@ message MsgCreateAuction { (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; + + string beneficiary = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } message MsgCreateAuctionResponse {} @@ -105,6 +107,8 @@ message MsgUpdateAuction { (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; + + string beneficiary = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } message MsgUpdateAuctionResponse {} diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 92a745a49b..6c5e3be3a6 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -84,7 +84,7 @@ Example: func CmdCreateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "create-auction [denom] [enabled] [price-multiplier] [min-bid-amount]", + Use: "create-auction [denom] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", Short: "Create a new auction", Long: strings.TrimSpace( fmt.Sprintf(`Create a new auction for a specific token. @@ -113,6 +113,7 @@ Example: enabled, // enabled args[2], // price multiplier minBidAmount, // min bid amount + args[4], // beneficiary ) if err := msg.ValidateBasic(); err != nil { @@ -130,7 +131,7 @@ Example: func CmdUpdateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "update-auction [denom] [enabled] [price-multiplier] [min-bid-amount]", + Use: "update-auction [denom] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", Short: "Update an existing auction", Long: strings.TrimSpace( fmt.Sprintf(`Update an existing auction's parameters. @@ -159,6 +160,8 @@ Example: enabled, // enabled args[2], // price multiplier minBidAmount, // min bid amount + args[4], // beneficiary + ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index cf932a0e34..1188a0bb30 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -48,6 +48,7 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc Enabled: msg.Enabled, PriceMultiplier: msg.PriceMultiplier, MinBidAmount: msg.MinBidAmount, + Beneficiary: msg.Beneficiary, } err = ms.Keeper.SetAuction(ctx, auction) @@ -72,6 +73,7 @@ func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuc auction.Enabled = msg.Enabled auction.MinBidAmount = msg.MinBidAmount auction.PriceMultiplier = msg.PriceMultiplier + auction.Beneficiary = msg.Beneficiary err = ms.Keeper.SetAuction(ctx, auction) if err != nil { diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index 53924a7a10..0b143a74f9 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -6,6 +6,7 @@ package types import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -70,10 +71,11 @@ type Auction struct { PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + Beneficiary string `protobuf:"bytes,5,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` // Total amount of STRD burned - TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` + TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` // Total amount of tokens sold - TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` + TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` } func (m *Auction) Reset() { *m = Auction{} } @@ -123,6 +125,13 @@ func (m *Auction) GetEnabled() bool { return false } +func (m *Auction) GetBeneficiary() string { + if m != nil { + return m.Beneficiary + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "stride.auction.Params") proto.RegisterType((*Auction)(nil), "stride.auction.Auction") @@ -131,29 +140,32 @@ func init() { func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_739480caccbf7be9) } var fileDescriptor_739480caccbf7be9 = []byte{ - // 349 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xcb, 0x4e, 0xf2, 0x40, - 0x18, 0x86, 0x5b, 0xfe, 0x9f, 0x83, 0x13, 0x03, 0xda, 0x60, 0xd2, 0x78, 0x28, 0x04, 0x37, 0x6c, - 0x6c, 0xe3, 0xe1, 0x06, 0xa8, 0x6e, 0x88, 0x68, 0x4c, 0x71, 0xe5, 0xa6, 0x99, 0x76, 0x26, 0x65, - 0x42, 0x67, 0xa6, 0x99, 0x99, 0x1a, 0xb9, 0x0b, 0x2f, 0x8b, 0x25, 0x4b, 0xe3, 0x82, 0x18, 0xf0, - 0x42, 0x0c, 0x53, 0xc0, 0x85, 0x1b, 0x56, 0x33, 0xdf, 0xf7, 0xbd, 0xcf, 0xb3, 0x79, 0xc1, 0xa9, - 0x54, 0x82, 0x20, 0xec, 0xc1, 0x3c, 0x56, 0x84, 0xb3, 0xcd, 0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9, 0x5d, 0xf5, 0xac, 0xb1, 0x21, 0x4f, 0x91, 0x7f, 0x3f, 0x5d, 0x38, 0xe6, 0x6c, 0xe1, 0x98, - 0x5f, 0x0b, 0xc7, 0x7c, 0x5f, 0x3a, 0xc6, 0x6c, 0xe9, 0x18, 0x1f, 0x4b, 0xc7, 0x78, 0xb9, 0x4c, - 0x88, 0x1a, 0xe5, 0x91, 0x1b, 0x73, 0xea, 0x0d, 0x75, 0x77, 0x17, 0x03, 0x18, 0x49, 0x6f, 0xdd, - 0xf2, 0xeb, 0xd5, 0x8d, 0xf7, 0xb6, 0xed, 0x5a, 0x4d, 0x32, 0x2c, 0xa3, 0x8a, 0x2e, 0xf1, 0xfa, - 0x27, 0x00, 0x00, 0xff, 0xff, 0x89, 0x6f, 0xef, 0x26, 0x0a, 0x02, 0x00, 0x00, + // 399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0xcf, 0xd2, 0x30, + 0x1c, 0xc7, 0x37, 0x1f, 0x1f, 0xc0, 0x6a, 0x40, 0x17, 0x4c, 0x2a, 0xea, 0x20, 0x78, 0xe1, 0xc2, + 0x16, 0xff, 0x9c, 0xbc, 0x31, 0xbd, 0x10, 0xd1, 0x98, 0xcd, 0x93, 0x97, 0xa5, 0x5b, 0xeb, 0x68, + 0x58, 0xdb, 0xa5, 0xed, 0x8c, 0xbc, 0x0b, 0x5f, 0x82, 0x2f, 0xc2, 0x17, 0xc1, 0x91, 0x78, 0x32, + 0x1e, 0x88, 0x81, 0x37, 0x62, 0x68, 0x07, 0x9a, 0x78, 0xe1, 0xb4, 0xfd, 0xf6, 0xfd, 0x7d, 0x3e, + 0x6b, 0x9a, 0x2f, 0x78, 0xa4, 0xb4, 0xa4, 0x98, 0x84, 0xa8, 0xce, 0x35, 0x15, 0xfc, 0xf4, 0x0c, + 0x2a, 0x29, 0xb4, 0xf0, 0xba, 0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, 0x1c, 0xdc, 0xd3, + 0x42, 0xa3, 0x32, 0x55, 0x5a, 0xe2, 0x34, 0xab, 0x25, 0x27, 0x18, 0xb6, 0x2e, 0x39, 0x43, 0xcf, + 0x70, 0x89, 0x96, 0x38, 0x32, 0xd4, 0x5f, 0x95, 0x16, 0x2b, 0xc2, 0x55, 0xaa, 0x44, 0x89, 0x61, + 0xfb, 0x72, 0xd5, 0x07, 0x83, 0x25, 0xa2, 0xc4, 0xd1, 0x9b, 0xcd, 0xde, 0x77, 0xb7, 0x7b, 0xdf, + 0xfd, 0xbd, 0xf7, 0xdd, 0xaf, 0x07, 0xdf, 0xd9, 0x1e, 0x7c, 0xe7, 0xe7, 0xc1, 0x77, 0x3e, 0x3e, + 0x2d, 0xa8, 0x5e, 0xd6, 0x59, 0x90, 0x0b, 0x16, 0x26, 0xa6, 0x12, 0xd3, 0x05, 0xca, 0x54, 0xd8, + 0x94, 0xe7, 0xf3, 0xb3, 0x17, 0xe1, 0x97, 0x73, 0x85, 0xf4, 0xba, 0x22, 0x2a, 0x6b, 0x99, 0x02, + 0x3c, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xd4, 0x87, 0x86, 0x61, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -208,7 +220,7 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a { size := m.TotalStrdBurned.Size() i -= size @@ -218,7 +230,14 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 + if len(m.Beneficiary) > 0 { + i -= len(m.Beneficiary) + copy(dAtA[i:], m.Beneficiary) + i = encodeVarintAuction(dAtA, i, uint64(len(m.Beneficiary))) + i-- + dAtA[i] = 0x2a + } { size := m.MinBidAmount.Size() i -= size @@ -296,6 +315,10 @@ func (m *Auction) Size() (n int) { n += 1 + l + sovAuction(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovAuction(uint64(l)) + l = len(m.Beneficiary) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } l = m.TotalStrdBurned.Size() n += 1 + l + sovAuction(uint64(l)) l = m.TotalTokensSold.Size() @@ -509,6 +532,38 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beneficiary = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalStrdBurned", wireType) } @@ -542,7 +597,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalTokensSold", wireType) } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 735b9ac0de..682155b614 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -88,6 +88,7 @@ func NewMsgCreateAuction(admin string, enabled bool, priceMultiplier string, minBidAmount uint64, + beneficiary string, ) *MsgCreateAuction { priceMultiplierDec, err := math.LegacyNewDecFromStr(priceMultiplier) if err != nil { @@ -100,6 +101,7 @@ func NewMsgCreateAuction(admin string, Enabled: enabled, PriceMultiplier: priceMultiplierDec, MinBidAmount: math.NewIntFromUint64(minBidAmount), + Beneficiary: beneficiary, } } @@ -137,6 +139,9 @@ func (msg *MsgCreateAuction) ValidateBasic() error { if msg.PriceMultiplier.IsZero() { return errors.New("price-multiplier cannot be 0") } + if _, err := sdk.AccAddressFromBech32(msg.Beneficiary); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } return nil } @@ -150,6 +155,7 @@ func NewMsgUpdateAuction(admin string, enabled bool, priceMultiplier string, minBidAmount uint64, + beneficiary string, ) *MsgUpdateAuction { priceMultiplierDec, err := math.LegacyNewDecFromStr(priceMultiplier) if err != nil { @@ -162,6 +168,7 @@ func NewMsgUpdateAuction(admin string, Enabled: enabled, PriceMultiplier: priceMultiplierDec, MinBidAmount: math.NewIntFromUint64(minBidAmount), + Beneficiary: beneficiary, } } @@ -199,6 +206,9 @@ func (msg *MsgUpdateAuction) ValidateBasic() error { if msg.PriceMultiplier.IsZero() { return errors.New("price-multiplier cannot be 0") } + if _, err := sdk.AccAddressFromBech32(msg.Beneficiary); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + } return nil } diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index 6abd255007..555fc038d8 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -139,6 +139,7 @@ type MsgCreateAuction struct { PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + Beneficiary string `protobuf:"bytes,6,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` } func (m *MsgCreateAuction) Reset() { *m = MsgCreateAuction{} } @@ -195,6 +196,13 @@ func (m *MsgCreateAuction) GetEnabled() bool { return false } +func (m *MsgCreateAuction) GetBeneficiary() string { + if m != nil { + return m.Beneficiary + } + return "" +} + type MsgCreateAuctionResponse struct { } @@ -243,6 +251,7 @@ type MsgUpdateAuction struct { PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + Beneficiary string `protobuf:"bytes,6,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` } func (m *MsgUpdateAuction) Reset() { *m = MsgUpdateAuction{} } @@ -299,6 +308,13 @@ func (m *MsgUpdateAuction) GetEnabled() bool { return false } +func (m *MsgUpdateAuction) GetBeneficiary() string { + if m != nil { + return m.Beneficiary + } + return "" +} + type MsgUpdateAuctionResponse struct { } @@ -347,43 +363,45 @@ func init() { func init() { proto.RegisterFile("stride/auction/tx.proto", fileDescriptor_07b888fb549a7ca8) } var fileDescriptor_07b888fb549a7ca8 = []byte{ - // 574 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0xe3, 0x94, 0x94, 0x72, 0xfd, 0x43, 0x39, 0x52, 0xd5, 0xb8, 0xe0, 0x94, 0x74, 0xa9, - 0x22, 0x6a, 0xb7, 0x85, 0x89, 0x89, 0xa4, 0x5d, 0x10, 0x09, 0x42, 0xae, 0x58, 0x60, 0x88, 0x6c, - 0xdf, 0xc9, 0x3d, 0x35, 0xbe, 0xb3, 0x7c, 0xe7, 0xaa, 0xdd, 0x10, 0x23, 0x13, 0x43, 0x3f, 0x48, - 0x06, 0x16, 0xbe, 0x41, 0xc7, 0x8a, 0x09, 0x31, 0x54, 0x28, 0x19, 0xf2, 0x35, 0x90, 0x7d, 0x97, - 0xc8, 0x2e, 0x11, 0xe9, 0x07, 0x60, 0x49, 0xf2, 0xbe, 0xf7, 0x3c, 0x8f, 0xf2, 0xfe, 0x5e, 0xfb, - 0xc0, 0x3a, 0x17, 0x31, 0x41, 0xd8, 0x76, 0x13, 0x5f, 0x10, 0x46, 0x6d, 0x71, 0x66, 0x45, 0x31, - 0x13, 0x0c, 0xae, 0xc8, 0x03, 0x4b, 0x1d, 0x18, 0xeb, 0x3e, 0xe3, 0x21, 0xe3, 0x76, 0xc8, 0x03, - 0xfb, 0x74, 0x2f, 0xfd, 0x92, 0x42, 0xe3, 0x81, 0x1b, 0x12, 0xca, 0xec, 0xec, 0x53, 0xb5, 0x1e, - 0x49, 0x6d, 0x37, 0xab, 0x6c, 0x59, 0xa8, 0xa3, 0x6a, 0xc0, 0x02, 0x26, 0xfb, 0xe9, 0x2f, 0xd9, - 0xad, 0x5f, 0x94, 0xc1, 0x62, 0x87, 0x07, 0xef, 0x7a, 0xae, 0x8f, 0x5b, 0x04, 0xc1, 0x5d, 0x30, - 0xef, 0x11, 0x84, 0x70, 0xac, 0x6b, 0x9b, 0xda, 0xf6, 0xbd, 0x96, 0xfe, 0xe3, 0xdb, 0x4e, 0x55, - 0xe5, 0x34, 0x11, 0x8a, 0x31, 0xe7, 0x47, 0x22, 0x26, 0x34, 0x70, 0x94, 0x0e, 0xd6, 0xc0, 0xa2, - 0x60, 0x27, 0x98, 0x76, 0x11, 0xa6, 0x2c, 0xd4, 0xcb, 0xa9, 0xcd, 0x01, 0x59, 0xeb, 0x30, 0xed, - 0xc0, 0x16, 0x58, 0x4e, 0xa4, 0xc2, 0x0d, 0x59, 0x42, 0x85, 0x3e, 0x97, 0x25, 0x3f, 0xb9, 0xbc, - 0xae, 0x95, 0x7e, 0x5d, 0xd7, 0xd6, 0x64, 0x3a, 0x47, 0x27, 0x16, 0x61, 0x76, 0xe8, 0x8a, 0x63, - 0xeb, 0x35, 0x15, 0xce, 0x92, 0xf4, 0x34, 0x33, 0x0b, 0x7c, 0x05, 0x96, 0x12, 0x2e, 0x62, 0x34, - 0x8e, 0xb8, 0x73, 0x9b, 0x88, 0xc5, 0xcc, 0x22, 0x13, 0x5e, 0x3e, 0xfb, 0x3c, 0xea, 0x37, 0xd4, - 0x7f, 0xfe, 0x32, 0xea, 0x37, 0x1e, 0x2b, 0xfc, 0x67, 0x93, 0x05, 0xe4, 0x30, 0xd4, 0xd7, 0xc0, - 0xc3, 0x5c, 0xe9, 0x60, 0x1e, 0x31, 0xca, 0x71, 0xfd, 0x7b, 0x19, 0xac, 0x76, 0x78, 0x70, 0x10, - 0x63, 0x57, 0xe0, 0xa6, 0xf4, 0x41, 0x0b, 0x54, 0x5c, 0x14, 0x12, 0x3a, 0x93, 0x98, 0x94, 0xc1, - 0x2a, 0xa8, 0xe4, 0x51, 0xc9, 0x02, 0xea, 0xe0, 0x2e, 0xa6, 0xae, 0xd7, 0xc3, 0x28, 0xe3, 0xb3, - 0xe0, 0x8c, 0x4b, 0xf8, 0x16, 0xac, 0x46, 0x31, 0xf1, 0x71, 0x37, 0x4c, 0x7a, 0x82, 0x44, 0x3d, - 0x82, 0x63, 0x35, 0xff, 0x96, 0x9a, 0x7f, 0xe3, 0xef, 0xf9, 0xdb, 0x38, 0x70, 0xfd, 0xf3, 0x43, - 0xec, 0x3b, 0xf7, 0x33, 0x73, 0x67, 0xe2, 0x85, 0x07, 0x60, 0x25, 0x24, 0xb4, 0xeb, 0x91, 0x09, - 0xcd, 0xca, 0xad, 0x16, 0x12, 0x12, 0xda, 0x22, 0x63, 0x9c, 0xbb, 0x29, 0x4e, 0x39, 0x50, 0x4a, - 0xf3, 0xe9, 0x34, 0x9a, 0x05, 0x4c, 0x75, 0x03, 0xe8, 0x37, 0x7b, 0x37, 0xb9, 0xbe, 0x8f, 0xd0, - 0x7f, 0xae, 0xb3, 0xb9, 0x16, 0x30, 0x29, 0xae, 0x85, 0xde, 0x98, 0xeb, 0xfe, 0x45, 0x19, 0xcc, - 0x75, 0x78, 0x00, 0xdb, 0x60, 0x61, 0xf2, 0x86, 0x6f, 0x58, 0xc5, 0xfb, 0xc5, 0xca, 0x3d, 0xe8, - 0xc6, 0xd6, 0x3f, 0x0e, 0xc7, 0xa9, 0xf0, 0x23, 0x58, 0x2e, 0xbe, 0x01, 0x9b, 0x53, 0x5c, 0x05, - 0x85, 0xb1, 0x3d, 0x4b, 0x91, 0x0f, 0x2f, 0x3e, 0x06, 0xd3, 0xc2, 0x0b, 0x8a, 0xa9, 0xe1, 0x53, - 0x79, 0x18, 0x95, 0x4f, 0xa3, 0x7e, 0x43, 0x6b, 0xbd, 0xb9, 0x1c, 0x98, 0xda, 0xd5, 0xc0, 0xd4, - 0x7e, 0x0f, 0x4c, 0xed, 0xeb, 0xd0, 0x2c, 0x5d, 0x0d, 0xcd, 0xd2, 0xcf, 0xa1, 0x59, 0xfa, 0xb0, - 0x17, 0x10, 0x71, 0x9c, 0x78, 0x96, 0xcf, 0x42, 0xfb, 0x28, 0x0b, 0xdd, 0x69, 0xbb, 0x1e, 0xb7, - 0xd5, 0x1a, 0x4e, 0xf7, 0x5f, 0xe4, 0x56, 0x21, 0xce, 0x23, 0xcc, 0xbd, 0xf9, 0xec, 0x22, 0x7d, - 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xd3, 0x67, 0x07, 0xd0, 0x05, 0x00, 0x00, + // 595 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x54, 0xb1, 0x6f, 0xd3, 0x4e, + 0x18, 0x8d, 0xd3, 0x5f, 0xfa, 0x2b, 0x97, 0xb6, 0x94, 0xa3, 0x55, 0x8d, 0x0b, 0x6e, 0x49, 0x97, + 0xaa, 0xa2, 0x76, 0x5b, 0x98, 0x3a, 0x91, 0xb4, 0x0b, 0x22,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xb4, 0x41, 0x94, 0x9d, 0xf0, 0x00, 0x54, 0x3d, 0x4c, + 0xf1, 0x7b, 0xe2, 0x13, 0x37, 0xee, 0xea, 0xb3, 0x53, 0x56, 0xcf, 0x83, 0x0f, 0x76, 0xd3, 0x28, + 0xa4, 0x19, 0x69, 0x12, 0x8f, 0x27, 0x25, 0x51, 0xb0, 0xb8, 0x66, 0x00, 0xfd, 0x66, 0xef, 0x66, + 0x26, 0x6f, 0x22, 0xf4, 0x2f, 0x93, 0xbf, 0x9b, 0x49, 0xc1, 0x62, 0x95, 0x49, 0xa1, 0x37, 0xca, + 0x64, 0xff, 0xa2, 0x0c, 0x66, 0x5a, 0x3c, 0x80, 0x4d, 0x30, 0x37, 0xbe, 0x59, 0xd6, 0xac, 0xe2, + 0xbd, 0x66, 0xe5, 0x0e, 0x98, 0xb1, 0xf9, 0x87, 0xe1, 0x48, 0x15, 0xbe, 0x03, 0x0b, 0xc5, 0x93, + 0xb7, 0x31, 0x81, 0x55, 0x40, 0x18, 0x5b, 0xd3, 0x10, 0x79, 0xf1, 0xe2, 0x27, 0x34, 0x49, 0xbc, + 0x80, 0x98, 0x28, 0x3e, 0xd1, 0x0f, 0xa3, 0xf2, 0x61, 0xd8, 0xdb, 0xd6, 0x1a, 0x2f, 0x2f, 0xfb, + 0xa6, 0x76, 0xd5, 0x37, 0xb5, 0x1f, 0x7d, 0x53, 0xfb, 0x3c, 0x30, 0x4b, 0x57, 0x03, 0xb3, 0xf4, + 0x6d, 0x60, 0x96, 0xde, 0xee, 0x05, 0x44, 0x9c, 0x24, 0x9e, 0xe5, 0xb3, 0xd0, 0x3e, 0xce, 0x44, + 0x77, 0x9a, 0xae, 0xc7, 0x6d, 0x15, 0xc3, 0xd9, 0xfe, 0xb3, 0x5c, 0x14, 0xa2, 0x1b, 0x61, 0xee, + 0xcd, 0x66, 0x17, 0xf8, 0xd3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xe7, 0x89, 0x74, 0x48, + 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -644,6 +662,13 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Beneficiary) > 0 { + i -= len(m.Beneficiary) + copy(dAtA[i:], m.Beneficiary) + i = encodeVarintTx(dAtA, i, uint64(len(m.Beneficiary))) + i-- + dAtA[i] = 0x32 + } { size := m.MinBidAmount.Size() i -= size @@ -734,6 +759,13 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Beneficiary) > 0 { + i -= len(m.Beneficiary) + copy(dAtA[i:], m.Beneficiary) + i = encodeVarintTx(dAtA, i, uint64(len(m.Beneficiary))) + i-- + dAtA[i] = 0x32 + } { size := m.MinBidAmount.Size() i -= size @@ -866,6 +898,10 @@ func (m *MsgCreateAuction) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Beneficiary) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -899,6 +935,10 @@ func (m *MsgUpdateAuction) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Beneficiary) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1330,6 +1370,38 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beneficiary = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1582,6 +1654,38 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beneficiary = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 3e29cbf941ab466ca555adae96f4c333f39adb89 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 12 Dec 2024 23:15:22 +0200 Subject: [PATCH 017/115] implement FCFS auction type + rename a bunch of stuff --- proto/stride/auction/auction.proto | 27 ++- proto/stride/auction/query.proto | 4 +- proto/stride/auction/tx.proto | 39 ++-- proto/stride/icqoracle/icqoracle.proto | 8 +- proto/stride/icqoracle/tx.proto | 12 +- x/auction/client/cli/tx.go | 22 ++- x/auction/keeper/auction_handlers.go | 1 + x/auction/keeper/keeper.go | 166 ++++++++++++++-- x/auction/keeper/msg_server.go | 2 + x/auction/types/auction.pb.go | 163 +++++++++++----- x/auction/types/expected_keepers.go | 15 +- x/auction/types/msgs.go | 37 +++- x/auction/types/query.pb.go | 40 ++-- x/auction/types/tx.pb.go | 256 ++++++++++++++++--------- x/icqoracle/keeper/keeper.go | 23 +++ x/icqoracle/types/icqoracle.pb.go | 8 +- x/icqoracle/types/keys.go | 4 + x/icqoracle/types/tx.pb.go | 12 +- 18 files changed, 590 insertions(+), 249 deletions(-) create mode 100644 x/auction/keeper/auction_handlers.go diff --git a/proto/stride/auction/auction.proto b/proto/stride/auction/auction.proto index f0aacc0b91..a088f95981 100644 --- a/proto/stride/auction/auction.proto +++ b/proto/stride/auction/auction.proto @@ -1,43 +1,52 @@ syntax = "proto3"; package stride.auction; -import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; -// Global auction parameters +enum AuctionType { + // Default value - should not be used + AUCTION_TYPE_UNSPECIFIED = 0; + // First-Come First-Served auction + AUCTION_TYPE_FCFS = 1; +} message Params {} message Auction { + // Auction type + AuctionType type = 1; + // Token denom being auctioned - string denom = 1; + string denom = 2; // Whether auction is active - bool enabled = 2; + bool enabled = 3; // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 3 [ + string price_multiplier = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Minimum STRD bid amount - string min_bid_amount = 4 [ + string min_bid_amount = 5 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; - string beneficiary = 5 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // Address to send the auction proceeds to + string beneficiary = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Total amount of STRD burned - string total_strd_burned = 6 [ + string total_strd_burned = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // Total amount of tokens sold - string total_tokens_sold = 7 [ + string total_tokens_sold = 8 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; diff --git a/proto/stride/auction/query.proto b/proto/stride/auction/query.proto index 34242d4433..c69cb555f9 100644 --- a/proto/stride/auction/query.proto +++ b/proto/stride/auction/query.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package stride.auction; -import "stride/auction/auction.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; +import "stride/auction/auction.proto"; option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; diff --git a/proto/stride/auction/tx.proto b/proto/stride/auction/tx.proto index 156d13dc04..e2ef2ced0f 100644 --- a/proto/stride/auction/tx.proto +++ b/proto/stride/auction/tx.proto @@ -1,10 +1,11 @@ syntax = "proto3"; package stride.auction; -import "cosmos/msg/v1/msg.proto"; import "amino/amino.proto"; import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; import "gogoproto/gogo.proto"; +import "stride/auction/auction.proto"; option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; @@ -34,16 +35,16 @@ message MsgPlaceBid { string bidder = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Token being bid on - string token_denom = 2; + string auction_token_denom = 2; // Amount of tokens requested in base units (utoken) - string utoken_amount = 3 [ + string auction_token_amount = 3 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // Amount of STRD being paid in base units (ustrd) - string ustrd_amount = 4 [ + string payment_token_amount = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; @@ -59,25 +60,28 @@ message MsgCreateAuction { // Admin's address string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Denom on Stride of the token being auctioned (e.g. "ibc/...") - string denom = 2; + // Auction type + AuctionType auction_type = 2; + + // Denom on Stride of the token being auctioned off (e.g. "ibc/...") + string denom = 3; // Whether auction is active - bool enabled = 3; + bool enabled = 4; // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 4 [ + string price_multiplier = 5 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Minimum STRD bid amount - string min_bid_amount = 5 [ + string min_bid_amount = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; - string beneficiary = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string beneficiary = 7 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } message MsgCreateAuctionResponse {} @@ -90,25 +94,28 @@ message MsgUpdateAuction { // Admin's address string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Token denom being updated - string denom = 2; + // Auction type + AuctionType auction_type = 2; + + // Denom on Stride of the token being auctioned (e.g. "ibc/...") + string denom = 3; // Whether auction is active - bool enabled = 3; + bool enabled = 4; // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 4 [ + string price_multiplier = 5 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Minimum STRD bid amount - string min_bid_amount = 5 [ + string min_bid_amount = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; - string beneficiary = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string beneficiary = 7 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } message MsgUpdateAuctionResponse {} diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index e7fd8cd5ff..d7d0b57f4b 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -8,13 +8,13 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; // TokenPrice stores latest price data for a token message TokenPrice { - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Token denom on Stride string base_denom = 1; - // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Quote denom on Stride string quote_denom = 2; - // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + // Token denom on Osmosis string osmosis_base_denom = 3; - // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + // Quote denom on Osmosis string osmosis_quote_denom = 4; // Pool ID on Osmosis string osmosis_pool_id = 5; diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index bba1684b00..b3b2ef3739 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -26,13 +26,13 @@ message MsgAddTokenPrice { string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Token denom on Stride string base_denom = 2; - // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Quote denom on Stride string quote_denom = 3; - // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + // Token denom on Osmosis string osmosis_base_denom = 4; - // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + // Quote denom on Osmosis string osmosis_quote_denom = 5; // Pool ID on Osmosis string osmosis_pool_id = 6; @@ -47,9 +47,9 @@ message MsgRemoveTokenPrice { option (amino.name) = "stride/x/icqoracle/MsgRemoveTokenPrice"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Token denom on Stride string base_denom = 2; - // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Quote denom on Stride string quote_denom = 3; // Pool ID on Osmosis string osmosis_pool_id = 4; diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 6c5e3be3a6..1fe6b32888 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -109,11 +109,12 @@ Example: msg := types.NewMsgCreateAuction( clientCtx.GetFromAddress().String(), - args[0], // denom - enabled, // enabled - args[2], // price multiplier - minBidAmount, // min bid amount - args[4], // beneficiary + types.AuctionType_AUCTION_TYPE_FCFS, // auction type + args[0], // denom + enabled, // enabled + args[2], // price multiplier + minBidAmount, // min bid amount + args[4], // beneficiary ) if err := msg.ValidateBasic(); err != nil { @@ -156,11 +157,12 @@ Example: msg := types.NewMsgUpdateAuction( clientCtx.GetFromAddress().String(), - args[0], // denom - enabled, // enabled - args[2], // price multiplier - minBidAmount, // min bid amount - args[4], // beneficiary + types.AuctionType_AUCTION_TYPE_FCFS, // auction type + args[0], // denom + enabled, // enabled + args[2], // price multiplier + minBidAmount, // min bid amount + args[4], // beneficiary ) diff --git a/x/auction/keeper/auction_handlers.go b/x/auction/keeper/auction_handlers.go new file mode 100644 index 0000000000..b55569d4a4 --- /dev/null +++ b/x/auction/keeper/auction_handlers.go @@ -0,0 +1 @@ +package keeper diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index d45e592b25..1bc4fac8e8 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -13,10 +14,11 @@ import ( ) type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + icqoracleKeeper types.IcqOracleKeeper } func NewKeeper( @@ -24,12 +26,14 @@ func NewKeeper( storeKey storetypes.StoreKey, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + icqoracleKeeper types.IcqOracleKeeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, + cdc: cdc, + storeKey: storeKey, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + icqoracleKeeper: icqoracleKeeper, } } @@ -43,7 +47,7 @@ func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) error { key := types.AuctionKey(auction.Denom) bz, err := k.cdc.Marshal(&auction) if err != nil { - return err + return fmt.Errorf("error setting auction for denom '%s': %w", auction.Denom, err) } store.Set(key, bz) @@ -57,12 +61,12 @@ func (k Keeper) GetAuction(ctx sdk.Context, denom string) (types.Auction, error) bz := store.Get(key) if bz == nil { - return types.Auction{}, fmt.Errorf("auction not found for denom='%s'", denom) + return types.Auction{}, fmt.Errorf("auction not found for denom '%s'", denom) } var auction types.Auction if err := k.cdc.Unmarshal(bz, &auction); err != nil { - return types.Auction{}, err + return types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.Denom, err) } return auction, nil @@ -84,30 +88,150 @@ func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { return auctions } -// SetAuction stores auction info for a token +// PlaceBid places an auction bid and executes it based on the auction type func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { // Get auction - auction, err := k.GetAuction(ctx, bid.TokenDenom) + auction, err := k.GetAuction(ctx, bid.AuctionTokenDenom) if err != nil { - return fmt.Errorf("cannot get auction for denom='%s': %w", bid.TokenDenom, err) + return fmt.Errorf("cannot get auction for denom='%s': %w", bid.AuctionTokenDenom, err) } + // TODO check auction type and call handler + // Get token amount being auctioned off moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.Denom) - tokenAmount := balance.Amount + tokenAmountAvailable := balance.Amount // Verify auction has enough tokens to service the bid amount - if bid.UtokenAmount.GT(tokenAmount) { + if bid.AuctionTokenAmount.GT(tokenAmountAvailable) { return fmt.Errorf("bid wants %s%s but auction has only %s%s", - bid.UtokenAmount.String(), - bid.TokenDenom, - tokenAmount.String(), - bid.TokenDenom, + bid.AuctionTokenAmount.String(), + auction.Denom, + tokenAmountAvailable.String(), + auction.Denom, + ) + } + + auctionTokenPrices, err := k.icqoracleKeeper.GetTokenPricesByDenom(ctx, auction.Denom) + if err != nil { + return fmt.Errorf("error getting price for '%s': %w", auction.Denom, err) + } + if len(auctionTokenPrices) == 0 { + return fmt.Errorf("no price for '%s'", auction.Denom) + } + + paymentTokenDenom := "ustrd" // TODO fix + paymentTokenPrices, err := k.icqoracleKeeper.GetTokenPricesByDenom(ctx, paymentTokenDenom) + if err != nil { + return fmt.Errorf("error getting price for '%s': %w", paymentTokenDenom, err) + } + if len(paymentTokenPrices) == 0 { + return fmt.Errorf("no price for '%s'", paymentTokenDenom) + } + + // Get price staleness timeout + priceStaleTimeoutSec := int64(k.icqoracleKeeper.GetParams(ctx).PriceStaleTimeoutSec) + + // Find a common quote denom and calculate auctionToken-paymentToken price + auctionTokenToPaymentTokenPrice := math.LegacyZeroDec() + foundCommonQuoteToken := false + foundAuctionTokenStalePrice := false + foundPaymentTokenStalePrice := false + for quoteDenom1, auctionTokenPrice := range auctionTokenPrices { + for quoteDenom2, paymentTokenPrice := range paymentTokenPrices { + if quoteDenom1 == quoteDenom2 { + foundCommonQuoteToken = true + + // Check that prices are not stale + if ctx.BlockTime().Unix()-auctionTokenPrice.UpdatedAt.Unix() > priceStaleTimeoutSec { + foundAuctionTokenStalePrice = true + continue + } + if ctx.BlockTime().Unix()-paymentTokenPrice.UpdatedAt.Unix() > priceStaleTimeoutSec { + foundPaymentTokenStalePrice = true + continue + } + + // Calculate the price of 1 auctionToken in paymentToken including auction discount + // i.e. baseToken = auctionToken, quoteToken = paymentToken + auctionTokenToPaymentTokenPrice = auctionTokenPrice.SpotPrice.Quo(paymentTokenPrice.SpotPrice).Mul(auction.PriceMultiplier) + break + } + } + } + + if auctionTokenToPaymentTokenPrice.IsZero() { + return fmt.Errorf( + "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundAuctionTokenStalePrice='%v', foundPaymentTokenStalePrice='%v')", + auction.Denom, + paymentTokenDenom, + foundCommonQuoteToken, + foundAuctionTokenStalePrice, + foundPaymentTokenStalePrice, + ) + } + + if bid.AuctionTokenAmount.ToLegacyDec().Mul(auctionTokenToPaymentTokenPrice).LT(bid.PaymentTokenAmount.ToLegacyDec()) { + return fmt.Errorf("bid price too low: offered %s%s for %s%s, minimum required is %s%s (price=%s %s/%s)", + bid.PaymentTokenAmount.String(), + paymentTokenDenom, + bid.AuctionTokenAmount.String(), + auction.Denom, + bid.AuctionTokenAmount.ToLegacyDec().Mul(auctionTokenToPaymentTokenPrice).String(), + paymentTokenDenom, + auctionTokenToPaymentTokenPrice.String(), + paymentTokenDenom, + auction.Denom, + ) + } + + // Execute the exchange + + // Safe to use MustAccAddressFromBech32 because bid.Bidder passed ValidateBasic + bidder := sdk.MustAccAddressFromBech32(bid.Bidder) + + // Send paymentToken to beneficiary + // TODO move this up to fail early if not enought funds? + err = k.bankKeeper.SendCoins( + ctx, + bidder, + sdk.MustAccAddressFromBech32(auction.Beneficiary), + sdk.NewCoins(sdk.NewCoin(paymentTokenDenom, bid.PaymentTokenAmount)), + ) + if err != nil { + return fmt.Errorf("failed to send payment tokens from bidder '%s' to beneficiary '%s': %w", + bid.Bidder, + auction.Beneficiary, + err, ) } - // TODO continue + // Send auctionToken to bidder + // TODO move this up to fail early if not enought funds? + err = k.bankKeeper.SendCoinsFromModuleToAccount( + ctx, + types.ModuleName, + bidder, + sdk.NewCoins(sdk.NewCoin(auction.Denom, bid.AuctionTokenAmount)), + ) + if err != nil { + return fmt.Errorf("failed to send auction tokens from module '%s' to bidder '%s': %w", + types.ModuleName, + bid.Bidder, + err, + ) + } + + auction.TotalTokensSold = auction.TotalTokensSold.Add(bid.AuctionTokenAmount) + auction.TotalStrdBurned = auction.TotalStrdBurned.Add(bid.PaymentTokenAmount) + + err = k.SetAuction(ctx, auction) + if err != nil { + return fmt.Errorf("failed to update auction stats") + } + + // TODO emit event return nil } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 1188a0bb30..f44e1dec03 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -44,6 +44,7 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc } auction := types.Auction{ + Type: msg.AuctionType, Denom: msg.Denom, Enabled: msg.Enabled, PriceMultiplier: msg.PriceMultiplier, @@ -70,6 +71,7 @@ func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuc return nil, types.ErrAuctionDoesntExist.Wrapf("cannot find auction for token '%s'", msg.Denom) } + auction.Type = msg.AuctionType auction.Enabled = msg.Enabled auction.MinBidAmount = msg.MinBidAmount auction.PriceMultiplier = msg.PriceMultiplier diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index 0b143a74f9..779201577d 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -25,7 +25,33 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Global auction parameters +type AuctionType int32 + +const ( + // Default value - should not be used + AuctionType_AUCTION_TYPE_UNSPECIFIED AuctionType = 0 + // First-Come First-Served auction + AuctionType_AUCTION_TYPE_FCFS AuctionType = 1 +) + +var AuctionType_name = map[int32]string{ + 0: "AUCTION_TYPE_UNSPECIFIED", + 1: "AUCTION_TYPE_FCFS", +} + +var AuctionType_value = map[string]int32{ + "AUCTION_TYPE_UNSPECIFIED": 0, + "AUCTION_TYPE_FCFS": 1, +} + +func (x AuctionType) String() string { + return proto.EnumName(AuctionType_name, int32(x)) +} + +func (AuctionType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_739480caccbf7be9, []int{0} +} + type Params struct { } @@ -63,19 +89,22 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo type Auction struct { + // Auction type + Type AuctionType `protobuf:"varint,1,opt,name=type,proto3,enum=stride.auction.AuctionType" json:"type,omitempty"` // Token denom being auctioned - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` // Whether auction is active - Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount - MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` - Beneficiary string `protobuf:"bytes,5,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + // Address to send the auction proceeds to + Beneficiary string `protobuf:"bytes,6,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` // Total amount of STRD burned - TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` + TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` // Total amount of tokens sold - TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` + TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` } func (m *Auction) Reset() { *m = Auction{} } @@ -111,6 +140,13 @@ func (m *Auction) XXX_DiscardUnknown() { var xxx_messageInfo_Auction proto.InternalMessageInfo +func (m *Auction) GetType() AuctionType { + if m != nil { + return m.Type + } + return AuctionType_AUCTION_TYPE_UNSPECIFIED +} + func (m *Auction) GetDenom() string { if m != nil { return m.Denom @@ -133,6 +169,7 @@ func (m *Auction) GetBeneficiary() string { } func init() { + proto.RegisterEnum("stride.auction.AuctionType", AuctionType_name, AuctionType_value) proto.RegisterType((*Params)(nil), "stride.auction.Params") proto.RegisterType((*Auction)(nil), "stride.auction.Auction") } @@ -140,32 +177,37 @@ func init() { func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_739480caccbf7be9) } var fileDescriptor_739480caccbf7be9 = []byte{ - // 399 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0xcf, 0xd2, 0x30, - 0x1c, 0xc7, 0x37, 0x1f, 0x1f, 0xc0, 0x6a, 0x40, 0x17, 0x4c, 0x2a, 0xea, 0x20, 0x78, 0xe1, 0xc2, - 0x16, 0xff, 0x9c, 0xbc, 0x31, 0xbd, 0x10, 0xd1, 0x98, 0xcd, 0x93, 0x97, 0xa5, 0x5b, 0xeb, 0x68, - 0x58, 0xdb, 0xa5, 0xed, 0x8c, 0xbc, 0x0b, 0x5f, 0x82, 0x2f, 0xc2, 0x17, 0xc1, 0x91, 0x78, 0x32, - 0x1e, 0x88, 0x81, 0x37, 0x62, 0x68, 0x07, 0x9a, 0x78, 0xe1, 0xb4, 0xfd, 0xf6, 0xfd, 0x7d, 0x3e, - 0x6b, 0x9a, 0x2f, 0x78, 0xa4, 0xb4, 0xa4, 0x98, 0x84, 0xa8, 0xce, 0x35, 0x15, 0xfc, 0xf4, 0x0c, - 0x2a, 0x29, 0xb4, 0xf0, 0xba, 0x36, 0x0d, 0x9a, 0xaf, 0x83, 0x7e, 0x21, 0x0a, 0x61, 0xa2, 0xf0, - 0xf8, 0x66, 0xb7, 0x06, 0x0f, 0x72, 0xa1, 0x98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f, - 0x70, 0x89, 0x96, 0x38, 0x32, 0xd4, 0x5f, 0x95, 0x16, 0x2b, 0xc2, 0x55, 0xaa, 0x44, 0x89, 0x61, - 0xfb, 0x72, 0xd5, 0x07, 0x83, 0x25, 0xa2, 0xc4, 0xd1, 0x9b, 0xcd, 0xde, 0x77, 0xb7, 0x7b, 0xdf, - 0xfd, 0xbd, 0xf7, 0xdd, 0xaf, 0x07, 0xdf, 0xd9, 0x1e, 0x7c, 0xe7, 0xe7, 0xc1, 0x77, 0x3e, 0x3e, - 0x2d, 0xa8, 0x5e, 0xd6, 0x59, 0x90, 0x0b, 0x16, 0x26, 0xa6, 0x12, 0xd3, 0x05, 0xca, 0x54, 0xd8, - 0x94, 0xe7, 0xf3, 0xb3, 0x17, 0xe1, 0x97, 0x73, 0x85, 0xf4, 0xba, 0x22, 0x2a, 0x6b, 0x99, 0x02, - 0x3c, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xd4, 0x87, 0x86, 0x61, 0x02, 0x00, 0x00, + // 472 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0x1b, 0xb6, 0xb5, 0xc5, 0x43, 0x5d, 0x67, 0x75, 0x92, 0xd9, 0x46, 0x56, 0x8d, 0x4b, + 0x85, 0xb4, 0x44, 0x0c, 0x4e, 0xdc, 0xda, 0xae, 0x95, 0x22, 0x46, 0xa9, 0x92, 0xee, 0x00, 0x97, + 0xc8, 0x89, 0x4d, 0x66, 0x2d, 0xb1, 0x23, 0xdb, 0x41, 0xf4, 0x2d, 0x78, 0x18, 0x1e, 0x62, 0xc7, + 0xc1, 0x09, 0x71, 0x98, 0x50, 0xfb, 0x22, 0xa8, 0x4e, 0x36, 0x36, 0xed, 0xb2, 0x53, 0xf2, 0x7d, + 0xdf, 0xff, 0xff, 0xf3, 0x27, 0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9, 0x5d, 0xc5, 0x44, 0x45, 0x75, 0x93, 0xba, 0x37, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x3b, 0xba, 0x22, 0x15, 0xd6, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -220,7 +262,7 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 { size := m.TotalStrdBurned.Size() i -= size @@ -230,13 +272,13 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a if len(m.Beneficiary) > 0 { i -= len(m.Beneficiary) copy(dAtA[i:], m.Beneficiary) i = encodeVarintAuction(dAtA, i, uint64(len(m.Beneficiary))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } { size := m.MinBidAmount.Size() @@ -247,7 +289,7 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a { size := m.PriceMultiplier.Size() i -= size @@ -257,7 +299,7 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 if m.Enabled { i-- if m.Enabled { @@ -266,14 +308,19 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if len(m.Denom) > 0 { i -= len(m.Denom) copy(dAtA[i:], m.Denom) i = encodeVarintAuction(dAtA, i, uint64(len(m.Denom))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintAuction(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -304,6 +351,9 @@ func (m *Auction) Size() (n int) { } var l int _ = l + if m.Type != 0 { + n += 1 + sovAuction(uint64(m.Type)) + } l = len(m.Denom) if l > 0 { n += 1 + l + sovAuction(uint64(l)) @@ -412,6 +462,25 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= AuctionType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } @@ -443,7 +512,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } @@ -463,7 +532,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } } m.Enabled = bool(v != 0) - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) } @@ -497,7 +566,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) } @@ -531,7 +600,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) } @@ -563,7 +632,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } m.Beneficiary = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalStrdBurned", wireType) } @@ -597,7 +666,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalTokensSold", wireType) } diff --git a/x/auction/types/expected_keepers.go b/x/auction/types/expected_keepers.go index 3df04c0cf2..edcfe9ead3 100644 --- a/x/auction/types/expected_keepers.go +++ b/x/auction/types/expected_keepers.go @@ -2,9 +2,11 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + + icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) -// Required BankKeeper functions +// Required AccountKeeper functions type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress } @@ -13,7 +15,14 @@ type AccountKeeper interface { type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin GetSupply(ctx sdk.Context, denom string) sdk.Coin - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error +} + +// Required IcqOracleKeeper functions +type IcqOracleKeeper interface { + GetParams(ctx sdk.Context) *icqoracletypes.Params + GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*icqoracletypes.TokenPrice, error) } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 682155b614..cc0d5d54f5 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -32,12 +32,17 @@ var ( // MsgPlaceBid // ---------------------------------------------- -func NewMsgPlaceBid(bidder, tokenDenom string, utokenAmount, ustrdAmount uint64) *MsgPlaceBid { +func NewMsgPlaceBid( + bidder string, + tokenDenom string, + auctionTokenAmount uint64, + paymentTokenAmount uint64, +) *MsgPlaceBid { return &MsgPlaceBid{ - Bidder: bidder, - TokenDenom: tokenDenom, - UtokenAmount: math.NewIntFromUint64(utokenAmount), - UstrdAmount: math.NewIntFromUint64(ustrdAmount), + Bidder: bidder, + AuctionTokenDenom: tokenDenom, + AuctionTokenAmount: math.NewIntFromUint64(auctionTokenAmount), + PaymentTokenAmount: math.NewIntFromUint64(paymentTokenAmount), } } @@ -66,13 +71,13 @@ func (msg *MsgPlaceBid) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Bidder); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } - if msg.TokenDenom == "" { + if msg.AuctionTokenDenom == "" { return errors.New("token-denom must be specified") } - if msg.UtokenAmount.IsZero() { + if msg.AuctionTokenAmount.IsZero() { return errors.New("utoken-amount cannot be 0") } - if msg.UstrdAmount.IsZero() { + if msg.PaymentTokenAmount.IsZero() { return errors.New("ustrd-amount cannot be 0") } @@ -83,7 +88,9 @@ func (msg *MsgPlaceBid) ValidateBasic() error { // MsgCreateAuction // ---------------------------------------------- -func NewMsgCreateAuction(admin string, +func NewMsgCreateAuction( + admin string, + auctionType AuctionType, denom string, enabled bool, priceMultiplier string, @@ -97,6 +104,7 @@ func NewMsgCreateAuction(admin string, return &MsgCreateAuction{ Admin: admin, + AuctionType: auctionType, Denom: denom, Enabled: enabled, PriceMultiplier: priceMultiplierDec, @@ -130,6 +138,9 @@ func (msg *MsgCreateAuction) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } + if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { + return errors.New("auction-type is invalid") + } if msg.Denom == "" { return errors.New("denom must be specified") } @@ -150,7 +161,9 @@ func (msg *MsgCreateAuction) ValidateBasic() error { // MsgUpdateAuction // ---------------------------------------------- -func NewMsgUpdateAuction(admin string, +func NewMsgUpdateAuction( + admin string, + auctionType AuctionType, denom string, enabled bool, priceMultiplier string, @@ -164,6 +177,7 @@ func NewMsgUpdateAuction(admin string, return &MsgUpdateAuction{ Admin: admin, + AuctionType: auctionType, Denom: denom, Enabled: enabled, PriceMultiplier: priceMultiplierDec, @@ -197,6 +211,9 @@ func (msg *MsgUpdateAuction) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } + if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { + return errors.New("auction-type is invalid") + } if msg.Denom == "" { return errors.New("denom must be specified") } diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index 26f13881d5..b4c6e7f8d2 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -235,31 +235,31 @@ var fileDescriptor_8113674a9412675c = []byte{ // 431 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x2e, 0x29, 0xca, 0x4c, 0x49, 0xd5, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, - 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xe9, 0x41, 0xe5, 0xa4, 0x64, 0xd0, - 0xd4, 0x42, 0x69, 0x88, 0x6a, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4, 0x82, - 0x8a, 0xca, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 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0xbb, 0x19, 0xae, 0x5c, 0xc8, 0x1d, 0xc5, 0x71, 0x4c, 0x60, 0xc7, 0xa9, 0x13, 0x74, 0x1c, 0xc4, 0x5e, 0x64, 0xd7, 0x19, 0x35, 0x33, 0x71, 0xb1, 0x82, 0x5d, 0x27, 0x54, 0xc7, 0xc5, 0x0e, 0xb5, 0x4d, 0x48, 0x19, 0xdd, 0x19, 0x58, 0xa2, 0x47, 0x4a, 0x05, 0xbf, 0x22, 0x88, 0x5d, 0x4a, 0x1a, 0x4d, 0x97, 0x9f, 0x4c, - 0x66, 0x52, 0x12, 0x52, 0x80, 0xa7, 0x2d, 0x58, 0x32, 0x80, 0xf1, 0xab, 0xc1, 0xf1, 0x5a, 0x2b, - 0x54, 0xc5, 0xc5, 0x01, 0x0b, 0x21, 0x21, 0xbc, 0x66, 0xc3, 0x62, 0x48, 0x4a, 0x95, 0x80, 0x2a, - 0xa8, 0x13, 0x14, 0xc1, 0x4e, 0x90, 0x16, 0x92, 0xc4, 0xe5, 0x84, 0x62, 0x27, 0xef, 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, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, - 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x06, 0xdb, 0xa6, 0xeb, 0x93, 0x98, 0x54, 0xac, 0x0f, 0xcd, 0x30, - 0x65, 0x46, 0x26, 0xfa, 0x15, 0x70, 0x73, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xa9, - 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xf9, 0x43, 0x5b, 0x81, 0x03, 0x00, 0x00, + 0x66, 0x52, 0x12, 0x52, 0x80, 0xc7, 0x3d, 0x2c, 0x61, 0xc1, 0xf8, 0xd5, 0xe0, 0x78, 0xad, 0x15, + 0xaa, 0xe2, 0xe2, 0x80, 0x85, 0x90, 0x10, 0x5e, 0xb3, 0x61, 0x31, 0x24, 0xa5, 0x4a, 0x40, 0x15, + 0xd4, 0x09, 0x8a, 0x60, 0x27, 0x48, 0x0b, 0x49, 0xe2, 0x72, 0x42, 0xb1, 0x93, 0xf7, 0x89, 0x47, + 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, + 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0x07, 0x83, 0x6d, 0xd3, 0xf5, 0x49, 0x4c, 0x2a, 0xd6, 0x87, 0x26, 0xe8, + 0x32, 0x23, 0x13, 0xfd, 0x0a, 0xb8, 0xb9, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x54, + 0x6d, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x44, 0x3c, 0x54, 0x81, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index 555fc038d8..debcc1eb5c 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -37,11 +37,11 @@ type MsgPlaceBid struct { // Bidder's address Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` // Token being bid on - TokenDenom string `protobuf:"bytes,2,opt,name=token_denom,json=tokenDenom,proto3" json:"token_denom,omitempty"` + AuctionTokenDenom string `protobuf:"bytes,2,opt,name=auction_token_denom,json=auctionTokenDenom,proto3" json:"auction_token_denom,omitempty"` // Amount of tokens requested in base units (utoken) - UtokenAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=utoken_amount,json=utokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"utoken_amount"` + AuctionTokenAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=auction_token_amount,json=auctionTokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"auction_token_amount"` // Amount of STRD being paid in base units (ustrd) - UstrdAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=ustrd_amount,json=ustrdAmount,proto3,customtype=cosmossdk.io/math.Int" json:"ustrd_amount"` + PaymentTokenAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=payment_token_amount,json=paymentTokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"payment_token_amount"` } func (m *MsgPlaceBid) Reset() { *m = MsgPlaceBid{} } @@ -84,9 +84,9 @@ func (m *MsgPlaceBid) GetBidder() string { return "" } -func (m *MsgPlaceBid) GetTokenDenom() string { +func (m *MsgPlaceBid) GetAuctionTokenDenom() string { if m != nil { - return m.TokenDenom + return m.AuctionTokenDenom } return "" } @@ -131,15 +131,17 @@ var xxx_messageInfo_MsgPlaceBidResponse proto.InternalMessageInfo type MsgCreateAuction struct { // Admin's address Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` - // Denom on Stride of the token being auctioned (e.g. "ibc/...") - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Auction type + AuctionType AuctionType `protobuf:"varint,2,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` + // Denom on Stride of the token being auctioned off (e.g. "ibc/...") + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` // Whether auction is active - Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount - MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` - Beneficiary string `protobuf:"bytes,6,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + Beneficiary string `protobuf:"bytes,7,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` } func (m *MsgCreateAuction) Reset() { *m = MsgCreateAuction{} } @@ -182,6 +184,13 @@ func (m *MsgCreateAuction) GetAdmin() string { return "" } +func (m *MsgCreateAuction) GetAuctionType() AuctionType { + if m != nil { + return m.AuctionType + } + return AuctionType_AUCTION_TYPE_UNSPECIFIED +} + func (m *MsgCreateAuction) GetDenom() string { if m != nil { return m.Denom @@ -243,15 +252,17 @@ var xxx_messageInfo_MsgCreateAuctionResponse proto.InternalMessageInfo type MsgUpdateAuction struct { // Admin's address Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` - // Token denom being updated - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // Auction type + AuctionType AuctionType `protobuf:"varint,2,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` + // Denom on Stride of the token being auctioned (e.g. "ibc/...") + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` // Whether auction is active - Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` // Minimum STRD bid amount - MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` - Beneficiary string `protobuf:"bytes,6,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + Beneficiary string `protobuf:"bytes,7,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` } func (m *MsgUpdateAuction) Reset() { *m = MsgUpdateAuction{} } @@ -294,6 +305,13 @@ func (m *MsgUpdateAuction) GetAdmin() string { return "" } +func (m *MsgUpdateAuction) GetAuctionType() AuctionType { + if m != nil { + return m.AuctionType + } + return AuctionType_AUCTION_TYPE_UNSPECIFIED +} + func (m *MsgUpdateAuction) GetDenom() string { if m != nil { return m.Denom @@ -363,45 +381,47 @@ func init() { func init() { proto.RegisterFile("stride/auction/tx.proto", fileDescriptor_07b888fb549a7ca8) } var fileDescriptor_07b888fb549a7ca8 = []byte{ - // 595 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x54, 0xb1, 0x6f, 0xd3, 0x4e, - 0x18, 0x8d, 0xd3, 0x5f, 0xfa, 0x2b, 0x97, 0xb6, 0x94, 0xa3, 0x55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, - 0xcd, 0x66, 0x17, 0xf8, 0xd3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xe7, 0x89, 0x74, 0x48, - 0x06, 0x00, 0x00, + // 634 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xb1, 0x53, 0xd4, 0x40, + 0x14, 0xc6, 0xef, 0xc0, 0x03, 0x5c, 0x10, 0x61, 0x39, 0x86, 0x18, 0x34, 0xe0, 0xd1, 0x30, 0x8c, + 0x24, 0x80, 0x56, 0x14, 0xce, 0x70, 0xd0, 0x38, 0x72, 0xea, 0x04, 0x6c, 0xb4, 0xb8, 0xd9, 0x64, + 0xd7, 0xb0, 0xc3, 0xed, 0x6e, 0x26, 0xbb, 0xc7, 0x70, 0x9d, 0x63, 0x69, 0x65, 0xe1, 0x1f, 0x42, + 0xa1, 0xb5, 0x2d, 0x25, 0x63, 0xe5, 0x58, 0x30, 0x0e, 0x14, 0xfc, 0x1b, 0x4e, 0xb2, 0x7b, 0x67, + 0x02, 0x37, 0x42, 0x69, 0x61, 0x73, 0xb9, 0xb7, 0xdf, 0x7b, 0xdf, 0xe6, 0xbe, 0xdf, 0xe6, 0x02, + 0x66, 0xa4, 0x4a, 0x28, 0x26, 0x1e, 0x6a, 0x87, 0x8a, 0x0a, 0xee, 0xa9, 0x43, 0x37, 0x4e, 0x84, + 0x12, 0x70, 0x5c, 0x0b, 0xae, 0x11, 0xec, 0x49, 0xc4, 0x28, 0x17, 0x5e, 0xf6, 0xa9, 0x5b, 0xec, + 0x7b, 0xa1, 0x90, 0x4c, 0xc8, 0x66, 0x56, 0x79, 0xba, 0x30, 0xd2, 0x8c, 0xae, 0x3c, 0x26, 0x23, + 0xef, 0x60, 0x35, 0xbd, 0x18, 0xa1, 0x1a, 0x89, 0x48, 0xe8, 0x81, 0xf4, 0x9b, 0x59, 0xbd, 0x7f, + 0xe9, 0x2e, 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0xae, + 0xf0, 0x2d, 0xb8, 0x53, 0x7c, 0xf2, 0xe7, 0xfb, 0x4c, 0x15, 0x3a, 0xec, 0xc5, 0xeb, 0x3a, 0xf2, + 0xe6, 0xc5, 0x23, 0xd8, 0xcf, 0xbc, 0xd0, 0xd1, 0xd7, 0xbc, 0x6f, 0x1e, 0x76, 0xe5, 0xfd, 0xc5, + 0xd1, 0x52, 0xb9, 0xfe, 0xfc, 0xf8, 0xcc, 0x29, 0x9f, 0x9c, 0x39, 0xe5, 0x5f, 0x67, 0x4e, 0xf9, + 0xd3, 0xb9, 0x53, 0x3a, 0x39, 0x77, 0x4a, 0x3f, 0xce, 0x9d, 0xd2, 0x9b, 0xd5, 0x88, 0xaa, 0xbd, + 0x76, 0xe0, 0x86, 0x82, 0x79, 0x3b, 0x99, 0xe9, 0xf2, 0x36, 0x0a, 0xa4, 0x67, 0x30, 0x1c, 0xac, + 0x3d, 0xc9, 0xa1, 0x48, 0x4f, 0xb8, 0x0c, 0x86, 0xb2, 0x77, 0xcd, 0xe3, 0xdf, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x2c, 0x09, 0x39, 0xd9, 0x11, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -583,9 +603,9 @@ func (m *MsgPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.UstrdAmount.Size() + size := m.PaymentTokenAmount.Size() i -= size - if _, err := m.UstrdAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.PaymentTokenAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -593,19 +613,19 @@ func (m *MsgPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 { - size := m.UtokenAmount.Size() + size := m.AuctionTokenAmount.Size() i -= size - if _, err := m.UtokenAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.AuctionTokenAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a - if len(m.TokenDenom) > 0 { - i -= len(m.TokenDenom) - copy(dAtA[i:], m.TokenDenom) - i = encodeVarintTx(dAtA, i, uint64(len(m.TokenDenom))) + if len(m.AuctionTokenDenom) > 0 { + i -= len(m.AuctionTokenDenom) + copy(dAtA[i:], m.AuctionTokenDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.AuctionTokenDenom))) i-- dAtA[i] = 0x12 } @@ -667,7 +687,7 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Beneficiary) i = encodeVarintTx(dAtA, i, uint64(len(m.Beneficiary))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } { size := m.MinBidAmount.Size() @@ -678,7 +698,7 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 { size := m.PriceMultiplier.Size() i -= size @@ -688,7 +708,7 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a if m.Enabled { i-- if m.Enabled { @@ -697,14 +717,19 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.Denom) > 0 { i -= len(m.Denom) copy(dAtA[i:], m.Denom) i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.AuctionType != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AuctionType)) + i-- + dAtA[i] = 0x10 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -764,7 +789,7 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Beneficiary) i = encodeVarintTx(dAtA, i, uint64(len(m.Beneficiary))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } { size := m.MinBidAmount.Size() @@ -775,7 +800,7 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 { size := m.PriceMultiplier.Size() i -= size @@ -785,7 +810,7 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a if m.Enabled { i-- if m.Enabled { @@ -794,14 +819,19 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.Denom) > 0 { i -= len(m.Denom) copy(dAtA[i:], m.Denom) i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.AuctionType != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AuctionType)) + i-- + dAtA[i] = 0x10 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -857,13 +887,13 @@ func (m *MsgPlaceBid) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.TokenDenom) + l = len(m.AuctionTokenDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.UtokenAmount.Size() + l = m.AuctionTokenAmount.Size() n += 1 + l + sovTx(uint64(l)) - l = m.UstrdAmount.Size() + l = m.PaymentTokenAmount.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -887,6 +917,9 @@ func (m *MsgCreateAuction) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.AuctionType != 0 { + n += 1 + sovTx(uint64(m.AuctionType)) + } l = len(m.Denom) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -924,6 +957,9 @@ func (m *MsgUpdateAuction) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.AuctionType != 0 { + n += 1 + sovTx(uint64(m.AuctionType)) + } l = len(m.Denom) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1020,7 +1056,7 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AuctionTokenDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1048,11 +1084,11 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TokenDenom = string(dAtA[iNdEx:postIndex]) + m.AuctionTokenDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UtokenAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AuctionTokenAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1080,13 +1116,13 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.UtokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.AuctionTokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UstrdAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PaymentTokenAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1114,7 +1150,7 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.UstrdAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PaymentTokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1251,6 +1287,25 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionType", wireType) + } + m.AuctionType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionType |= AuctionType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } @@ -1282,7 +1337,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { } m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } @@ -1302,7 +1357,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { } } m.Enabled = bool(v != 0) - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) } @@ -1336,7 +1391,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) } @@ -1370,7 +1425,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) } @@ -1535,6 +1590,25 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionType", wireType) + } + m.AuctionType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionType |= AuctionType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } @@ -1566,7 +1640,7 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { } m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } @@ -1586,7 +1660,7 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { } } m.Enabled = bool(v != 0) - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) } @@ -1620,7 +1694,7 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) } @@ -1654,7 +1728,7 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) } diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index faf00b740c..9a6970a5c5 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -114,6 +114,29 @@ func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (typ return price, nil } +// GetTokenPriceByDenom retrieves all price data for a base denom +func (k Keeper) GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*types.TokenPrice, error) { + store := ctx.KVStore(k.storeKey) + + // Create prefix iterator for all keys starting with baseDenom + iterator := sdk.KVStorePrefixIterator(store, types.TokenPriceByDenomKey(baseDenom)) + defer iterator.Close() + + prices := make(map[string]*types.TokenPrice) + + for ; iterator.Valid(); iterator.Next() { + var price types.TokenPrice + if err := k.cdc.Unmarshal(iterator.Value(), &price); err != nil { + return nil, err + } + + // Use quoteDenom as the map key + prices[price.QuoteDenom] = &price + } + + return prices, nil +} + // GetAllTokenPrices retrieves all stored token prices func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { store := ctx.KVStore(k.storeKey) diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 3a52ac9335..147463bf19 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -30,13 +30,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // TokenPrice stores latest price data for a token type TokenPrice struct { - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Token denom on Stride BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Quote denom on Stride QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` - // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + // Token denom on Osmosis OsmosisBaseDenom string `protobuf:"bytes,3,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` - // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + // Quote denom on Osmosis OsmosisQuoteDenom string `protobuf:"bytes,4,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis OsmosisPoolId string `protobuf:"bytes,5,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 45d60f2431..debd630c48 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -19,3 +19,7 @@ const ( func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { return []byte(fmt.Sprintf("%s%s%s%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) } + +func TokenPriceByDenomKey(baseDenom string) []byte { + return []byte(fmt.Sprintf("%s%s", KeyPricePrefix, baseDenom)) +} diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index fa1140be1f..9d576c55e0 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -33,13 +33,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgAddTokenPrice defines the message for adding a new token to track prices type MsgAddTokenPrice struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Token denom on Stride BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Quote denom on Stride QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` - // Token denom on Osmosis (e.g. "uosmo", "ibc/...") + // Token denom on Osmosis OsmosisBaseDenom string `protobuf:"bytes,4,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` - // Quote denom on Osmosis (e.g. "uosmo", "ibc/...") + // Quote denom on Osmosis OsmosisQuoteDenom string `protobuf:"bytes,5,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis OsmosisPoolId string `protobuf:"bytes,6,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` @@ -160,9 +160,9 @@ var xxx_messageInfo_MsgAddTokenPriceResponse proto.InternalMessageInfo // tracking type MsgRemoveTokenPrice struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Token denom on Stride BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` - // Quote denom on its base chain (e.g. "uosmo", "uatom", "udym") + // Quote denom on Stride QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` // Pool ID on Osmosis OsmosisPoolId string `protobuf:"bytes,4,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` From 2040e96f4c55d76d440ece47bb9d430fc659ccfa Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Fri, 13 Dec 2024 16:12:43 +0200 Subject: [PATCH 018/115] rename price_stale_timeout_sec to price_expiration_timeout_sec in icqoracle.proto and regenerate go bindings --- proto/stride/icqoracle/icqoracle.proto | 8 +- x/icqoracle/types/icqoracle.pb.go | 102 ++++++++++++------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index d7d0b57f4b..97d28489b3 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -53,10 +53,10 @@ message Params { (gogoproto.jsontag) = "update_interval_sec" ]; - // Max time before price is considered stale - uint64 price_stale_timeout_sec = 4 [ - (gogoproto.moretags) = "yaml:\"price_stale_timeout_sec\"", - (gogoproto.jsontag) = "price_stale_timeout_sec" + // Max time before price is considered stale/expired + uint64 price_expiration_timeout_sec = 4 [ + (gogoproto.moretags) = "yaml:\"price_expiration_timeout_sec\"", + (gogoproto.jsontag) = "price_expiration_timeout_sec" ]; // ICQ timeout diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 147463bf19..75b384f326 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -138,8 +138,8 @@ type Params struct { OsmosisConnectionId string `protobuf:"bytes,2,opt,name=osmosis_connection_id,json=osmosisConnectionId,proto3" json:"osmosis_connection_id" yaml:"osmosis_connection_id"` // Time between price updates UpdateIntervalSec uint64 `protobuf:"varint,3,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` - // Max time before price is considered stale - PriceStaleTimeoutSec uint64 `protobuf:"varint,4,opt,name=price_stale_timeout_sec,json=priceStaleTimeoutSec,proto3" json:"price_stale_timeout_sec" yaml:"price_stale_timeout_sec"` + // Max time before price is considered stale/expired + PriceExpirationTimeoutSec uint64 `protobuf:"varint,4,opt,name=price_expiration_timeout_sec,json=priceExpirationTimeoutSec,proto3" json:"price_expiration_timeout_sec" yaml:"price_expiration_timeout_sec"` // ICQ timeout IcqTimeoutSec uint64 `protobuf:"varint,5,opt,name=icq_timeout_sec,json=icqTimeoutSec,proto3" json:"icq_timeout_sec" yaml:"icq_timeout_sec"` } @@ -198,9 +198,9 @@ func (m *Params) GetUpdateIntervalSec() uint64 { return 0 } -func (m *Params) GetPriceStaleTimeoutSec() uint64 { +func (m *Params) GetPriceExpirationTimeoutSec() uint64 { if m != nil { - return m.PriceStaleTimeoutSec + return m.PriceExpirationTimeoutSec } return 0 } @@ -220,46 +220,46 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 610 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0x41, 0x6f, 0xd3, 0x30, - 0x1c, 0xc5, 0x1b, 0xd6, 0x8d, 0xd5, 0xd3, 0xd8, 0x96, 0x0d, 0x56, 0x15, 0x88, 0xab, 0x20, 0xa1, - 0x09, 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, 0xf7, 0xca, 0xfd, 0x36, 0x75, 0x69, 0x88, 0x61, 0x46, 0x78, 0x6f, - 0x49, 0x1d, 0xd6, 0xfd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x04, 0x20, 0xb2, 0x55, 0x04, - 0x00, 0x00, + // 617 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x1b, 0xd6, 0x8d, 0xd5, 0xd3, 0xd8, 0x96, 0xf1, 0xa7, 0x94, 0x51, 0x57, 0x99, 0x84, + 0x26, 0xc4, 0x12, 0x69, 0x83, 0x03, 0xdc, 0xc8, 0x86, 0x50, 0xa5, 0x21, 0x95, 0x6c, 0x1c, 0xe0, + 0x12, 0xb9, 0x8e, 0xc9, 0xac, 0x35, 0x71, 0x1a, 0x3b, 0xd3, 0xfa, 0x09, 0xe0, 0xb8, 0x3b, 0x5f, + 0x68, 0xc7, 0x1d, 0x11, 0x07, 0x83, 0xb6, 0x5b, 0x8f, 0xfd, 0x04, 0x28, 0x76, 0xd2, 0x95, 0x52, + 0xed, 0x96, 0x3c, 0xbf, 0xc7, 0xef, 0x63, 0xbf, 0xaf, 0x65, 0xd0, 0xe2, 0x22, 0xa5, 0x01, 0x71, + 0x28, 0xee, 0xb3, 0x14, 0xe1, 0xde, 0xc4, 0x97, 0x9d, 0xa4, 0x4c, 0x30, 0x73, 0x55, 0x3b, 0xec, + 0xb1, 0xde, 0xb8, 0x1f, 0xb2, 0x90, 0x29, 0xe8, 0xe4, 0x5f, 0xda, 0xd7, 0x80, 0x21, 0x63, 0x61, + 0x8f, 0x38, 0xea, 0xaf, 0x9b, 0x7d, 0x75, 0x04, 0x8d, 0x08, 0x17, 0x28, 0x4a, 0xb4, 0xc1, 0xfa, + 0x36, 0x07, 0xc0, 0x11, 0x3b, 0x21, 0x71, 0x27,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, 0xff, 0x4f, 0xf8, 0xbc, 0x0a, 0xdf, 0x1e, 0x4a, 0x38, 0x8d, + 0x46, 0x12, 0x3e, 0xd4, 0x79, 0x53, 0xc0, 0xf2, 0x96, 0x29, 0xee, 0xdf, 0x94, 0x75, 0x3f, 0x5c, + 0x5c, 0x35, 0x8d, 0xcb, 0xab, 0xa6, 0xf1, 0xe7, 0xaa, 0x69, 0x9c, 0x5f, 0x37, 0x2b, 0x97, 0xd7, + 0xcd, 0xca, 0xcf, 0xeb, 0x66, 0xe5, 0xcb, 0x6e, 0x48, 0xc5, 0x71, 0xd6, 0xb5, 0x31, 0x8b, 0x9c, + 0x43, 0xf5, 0x2a, 0x6c, 0x1f, 0xa0, 0x2e, 0x77, 0x8a, 0x37, 0xe4, 0x74, 0xe7, 0xa5, 0x73, 0x36, + 0xf1, 0x92, 0x88, 0x41, 0x42, 0x78, 0x77, 0x41, 0xdd, 0xe0, 0xdd, 0xbf, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x4d, 0x8e, 0x4f, 0xd6, 0x6a, 0x04, 0x00, 0x00, } func (m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -373,8 +373,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.PriceStaleTimeoutSec != 0 { - i = encodeVarintIcqoracle(dAtA, i, uint64(m.PriceStaleTimeoutSec)) + if m.PriceExpirationTimeoutSec != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.PriceExpirationTimeoutSec)) i-- dAtA[i] = 0x20 } @@ -464,8 +464,8 @@ func (m *Params) Size() (n int) { if m.UpdateIntervalSec != 0 { n += 1 + sovIcqoracle(uint64(m.UpdateIntervalSec)) } - if m.PriceStaleTimeoutSec != 0 { - n += 1 + sovIcqoracle(uint64(m.PriceStaleTimeoutSec)) + if m.PriceExpirationTimeoutSec != 0 { + n += 1 + sovIcqoracle(uint64(m.PriceExpirationTimeoutSec)) } if m.IcqTimeoutSec != 0 { n += 1 + sovIcqoracle(uint64(m.IcqTimeoutSec)) @@ -890,9 +890,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceStaleTimeoutSec", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PriceExpirationTimeoutSec", wireType) } - m.PriceStaleTimeoutSec = 0 + m.PriceExpirationTimeoutSec = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIcqoracle @@ -902,7 +902,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PriceStaleTimeoutSec |= uint64(b&0x7F) << shift + m.PriceExpirationTimeoutSec |= uint64(b&0x7F) << shift if b < 0x80 { break } From 1e629dd9ae8377e5473945498331907ac42359e8 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Fri, 13 Dec 2024 16:13:33 +0200 Subject: [PATCH 019/115] move common quote price calculation from auction to icqoracle --- x/auction/keeper/keeper.go | 66 +++------------------ x/auction/types/expected_keepers.go | 6 +- x/icqoracle/keeper/keeper.go | 91 +++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 62 deletions(-) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 1bc4fac8e8..9348a4c19c 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -3,7 +3,6 @@ package keeper import ( "fmt" - "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -113,74 +112,25 @@ func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { ) } - auctionTokenPrices, err := k.icqoracleKeeper.GetTokenPricesByDenom(ctx, auction.Denom) - if err != nil { - return fmt.Errorf("error getting price for '%s': %w", auction.Denom, err) - } - if len(auctionTokenPrices) == 0 { - return fmt.Errorf("no price for '%s'", auction.Denom) - } - paymentTokenDenom := "ustrd" // TODO fix - paymentTokenPrices, err := k.icqoracleKeeper.GetTokenPricesByDenom(ctx, paymentTokenDenom) - if err != nil { - return fmt.Errorf("error getting price for '%s': %w", paymentTokenDenom, err) - } - if len(paymentTokenPrices) == 0 { - return fmt.Errorf("no price for '%s'", paymentTokenDenom) - } - // Get price staleness timeout - priceStaleTimeoutSec := int64(k.icqoracleKeeper.GetParams(ctx).PriceStaleTimeoutSec) - - // Find a common quote denom and calculate auctionToken-paymentToken price - auctionTokenToPaymentTokenPrice := math.LegacyZeroDec() - foundCommonQuoteToken := false - foundAuctionTokenStalePrice := false - foundPaymentTokenStalePrice := false - for quoteDenom1, auctionTokenPrice := range auctionTokenPrices { - for quoteDenom2, paymentTokenPrice := range paymentTokenPrices { - if quoteDenom1 == quoteDenom2 { - foundCommonQuoteToken = true - - // Check that prices are not stale - if ctx.BlockTime().Unix()-auctionTokenPrice.UpdatedAt.Unix() > priceStaleTimeoutSec { - foundAuctionTokenStalePrice = true - continue - } - if ctx.BlockTime().Unix()-paymentTokenPrice.UpdatedAt.Unix() > priceStaleTimeoutSec { - foundPaymentTokenStalePrice = true - continue - } - - // Calculate the price of 1 auctionToken in paymentToken including auction discount - // i.e. baseToken = auctionToken, quoteToken = paymentToken - auctionTokenToPaymentTokenPrice = auctionTokenPrice.SpotPrice.Quo(paymentTokenPrice.SpotPrice).Mul(auction.PriceMultiplier) - break - } - } + price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.Denom, paymentTokenDenom) + if err != nil { } - if auctionTokenToPaymentTokenPrice.IsZero() { - return fmt.Errorf( - "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundAuctionTokenStalePrice='%v', foundPaymentTokenStalePrice='%v')", - auction.Denom, - paymentTokenDenom, - foundCommonQuoteToken, - foundAuctionTokenStalePrice, - foundPaymentTokenStalePrice, - ) - } + discountedPrice := price.Mul(auction.PriceMultiplier) - if bid.AuctionTokenAmount.ToLegacyDec().Mul(auctionTokenToPaymentTokenPrice).LT(bid.PaymentTokenAmount.ToLegacyDec()) { + if bid.AuctionTokenAmount.ToLegacyDec(). + Mul(discountedPrice). + LT(bid.PaymentTokenAmount.ToLegacyDec()) { return fmt.Errorf("bid price too low: offered %s%s for %s%s, minimum required is %s%s (price=%s %s/%s)", bid.PaymentTokenAmount.String(), paymentTokenDenom, bid.AuctionTokenAmount.String(), auction.Denom, - bid.AuctionTokenAmount.ToLegacyDec().Mul(auctionTokenToPaymentTokenPrice).String(), + bid.AuctionTokenAmount.ToLegacyDec().Mul(discountedPrice).String(), paymentTokenDenom, - auctionTokenToPaymentTokenPrice.String(), + discountedPrice.String(), paymentTokenDenom, auction.Denom, ) diff --git a/x/auction/types/expected_keepers.go b/x/auction/types/expected_keepers.go index edcfe9ead3..2b3956545f 100644 --- a/x/auction/types/expected_keepers.go +++ b/x/auction/types/expected_keepers.go @@ -1,9 +1,8 @@ package types import ( + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - - icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) // Required AccountKeeper functions @@ -23,6 +22,5 @@ type BankKeeper interface { // Required IcqOracleKeeper functions type IcqOracleKeeper interface { - GetParams(ctx sdk.Context) *icqoracletypes.Params - GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*icqoracletypes.TokenPrice, error) + GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, quoteDenom string) (price math.LegacyDec, err error) } diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 9a6970a5c5..421d45fa4d 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -137,6 +138,96 @@ func (k Keeper) GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[st return prices, nil } +// GetTokenPriceForQuoteDenom calculates and retrieves the exchange rate between two tokens. +// The exchange rate is determined by finding a common quote token between both tokens, +// and then dividing their respective spot prices. +// +// For example, if we have: +// - baseToken/USDC = 10 +// - quoteToken/USDC = 5 +// +// Then: +// - baseToken/quoteToken = 10/5 = 2 +// +// Parameters: +// - ctx: SDK Context for accessing the store +// - baseDenom: The denom of the token to get the price for +// - quoteDenom: The denom to price the base token in +// +// Returns: +// - math.LegacyDec: The exchange rate of 1 baseToken in terms of quoteToken +// - error: Returns an error if: +// - No prices exist for either token +// - No common quote token exists between the two tokens +// - All available prices with a common quote token are stale (exceeded the stale timeout) +func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, quoteDenom string) (price math.LegacyDec, err error) { + // Get all price for baseToken + baseTokenPrices, err := k.GetTokenPricesByDenom(ctx, baseDenom) + if err != nil { + return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", baseDenom, err) + } + if len(baseTokenPrices) == 0 { + return math.LegacyDec{}, fmt.Errorf("no price for '%s'", baseDenom) + } + + // Get all price for quoteToken + quoteTokenPrices, err := k.GetTokenPricesByDenom(ctx, quoteDenom) + if err != nil { + return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", quoteDenom, err) + } + if len(quoteTokenPrices) == 0 { + return math.LegacyDec{}, fmt.Errorf("no price for '%s'", quoteDenom) + } + + // Get price expiration timeout + priceExpirationTimeoutSec := int64(k.GetParams(ctx).PriceExpirationTimeoutSec) + + // Init price + price = math.LegacyZeroDec() + + // Define flags to allow for better error messages + foundCommonQuoteToken := false + foundBaseTokenStalePrice := false + foundQuoteTokenStalePrice := false + + // Find a common quote denom and calculate baseToken to quoteToken price + for quoteDenom1, baseTokenPrice := range baseTokenPrices { + for quoteDenom2, quoteTokenPrice := range quoteTokenPrices { + if quoteDenom1 == quoteDenom2 { + foundCommonQuoteToken = true + + // Check that both prices are not stale + if ctx.BlockTime().Unix()-baseTokenPrice.UpdatedAt.Unix() > priceExpirationTimeoutSec { + foundBaseTokenStalePrice = true + continue + } + if ctx.BlockTime().Unix()-quoteTokenPrice.UpdatedAt.Unix() > priceExpirationTimeoutSec { + foundQuoteTokenStalePrice = true + continue + } + + // Calculate the price of 1 baseToken in quoteToken + price = baseTokenPrice.SpotPrice.Quo(quoteTokenPrice.SpotPrice) + + break + } + } + } + + if price.IsZero() { + return math.LegacyDec{}, fmt.Errorf( + "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v')", + baseDenom, + quoteDenom, + foundCommonQuoteToken, + foundBaseTokenStalePrice, + foundQuoteTokenStalePrice, + ) + } + + return price, nil +} + // GetAllTokenPrices retrieves all stored token prices func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { store := ctx.KVStore(k.storeKey) From 61710b3e6b5785de644536fe41a972d00cccf017 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Fri, 13 Dec 2024 16:24:04 +0200 Subject: [PATCH 020/115] refactor PlaceBid() to use auction bid handlers --- x/auction/keeper/auction_handlers.go | 1 - x/auction/keeper/auction_type.go | 105 +++++++++++++++++++++++++++ x/auction/keeper/genesis.go | 2 +- x/auction/keeper/keeper.go | 105 +++------------------------ x/auction/keeper/msg_server.go | 2 +- x/auction/keeper/query.go | 2 +- 6 files changed, 120 insertions(+), 97 deletions(-) delete mode 100644 x/auction/keeper/auction_handlers.go create mode 100644 x/auction/keeper/auction_type.go diff --git a/x/auction/keeper/auction_handlers.go b/x/auction/keeper/auction_handlers.go deleted file mode 100644 index b55569d4a4..0000000000 --- a/x/auction/keeper/auction_handlers.go +++ /dev/null @@ -1 +0,0 @@ -package keeper diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go new file mode 100644 index 0000000000..2422813c20 --- /dev/null +++ b/x/auction/keeper/auction_type.go @@ -0,0 +1,105 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +// Define a type for bid handler functions +type AuctionBidHandler func(ctx sdk.Context, k Keeper, auction *types.Auction, bid *types.MsgPlaceBid) error + +// Map of auction types to their handlers +var bidHandlers = map[types.AuctionType]AuctionBidHandler{ + types.AuctionType_AUCTION_TYPE_FCFS: fcfsBidHandler, +} + +// fcfsBidHandler handles bids for First Come First Serve auctions +func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *types.MsgPlaceBid) error { + // Get token amount being auctioned off + moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) + balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.Denom) + tokenAmountAvailable := balance.Amount + + // Verify auction has enough tokens to service the bid amount + if bid.AuctionTokenAmount.GT(tokenAmountAvailable) { + return fmt.Errorf("bid wants %s%s but auction has only %s%s", + bid.AuctionTokenAmount.String(), + auction.Denom, + tokenAmountAvailable.String(), + auction.Denom, + ) + } + + paymentTokenDenom := "ustrd" // TODO fix + + price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.Denom, paymentTokenDenom) + if err != nil { + return err + } + + discountedPrice := price.Mul(auction.PriceMultiplier) + + if bid.AuctionTokenAmount.ToLegacyDec(). + Mul(discountedPrice). + LT(bid.PaymentTokenAmount.ToLegacyDec()) { + return fmt.Errorf("bid price too low: offered %s%s for %s%s, minimum required is %s%s (price=%s %s/%s)", + bid.PaymentTokenAmount.String(), + paymentTokenDenom, + bid.AuctionTokenAmount.String(), + auction.Denom, + bid.AuctionTokenAmount.ToLegacyDec().Mul(discountedPrice).String(), + paymentTokenDenom, + discountedPrice.String(), + paymentTokenDenom, + auction.Denom, + ) + } + + // Safe to use MustAccAddressFromBech32 because bid.Bidder passed ValidateBasic + bidder := sdk.MustAccAddressFromBech32(bid.Bidder) + + // Send paymentToken to beneficiary + err = k.bankKeeper.SendCoins( + ctx, + bidder, + sdk.MustAccAddressFromBech32(auction.Beneficiary), + sdk.NewCoins(sdk.NewCoin(paymentTokenDenom, bid.PaymentTokenAmount)), + ) + if err != nil { + return fmt.Errorf("failed to send payment tokens from bidder '%s' to beneficiary '%s': %w", + bid.Bidder, + auction.Beneficiary, + err, + ) + } + + // Send auctionToken to bidder + err = k.bankKeeper.SendCoinsFromModuleToAccount( + ctx, + types.ModuleName, + bidder, + sdk.NewCoins(sdk.NewCoin(auction.Denom, bid.AuctionTokenAmount)), + ) + if err != nil { + return fmt.Errorf("failed to send auction tokens from module '%s' to bidder '%s': %w", + types.ModuleName, + bid.Bidder, + err, + ) + } + + auction.TotalTokensSold = auction.TotalTokensSold.Add(bid.AuctionTokenAmount) + auction.TotalStrdBurned = auction.TotalStrdBurned.Add(bid.PaymentTokenAmount) + + err = k.SetAuction(ctx, auction) + if err != nil { + return fmt.Errorf("failed to update auction stats") + } + + // TODO emit event + + return nil +} diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 53b4e6d889..417631b184 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -10,7 +10,7 @@ import ( func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { k.SetParams(ctx, genState.Params) for _, auction := range genState.Auctions { - if err := k.SetAuction(ctx, auction); err != nil { + if err := k.SetAuction(ctx, &auction); err != nil { panic(err) } } diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 9348a4c19c..5a1e8dee7c 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -41,10 +41,10 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // SetAuction stores auction info for a token -func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) error { +func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { store := ctx.KVStore(k.storeKey) key := types.AuctionKey(auction.Denom) - bz, err := k.cdc.Marshal(&auction) + bz, err := k.cdc.Marshal(auction) if err != nil { return fmt.Errorf("error setting auction for denom '%s': %w", auction.Denom, err) } @@ -54,21 +54,21 @@ func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) error { } // GetAuction retrieves auction info for a token -func (k Keeper) GetAuction(ctx sdk.Context, denom string) (types.Auction, error) { +func (k Keeper) GetAuction(ctx sdk.Context, denom string) (*types.Auction, error) { store := ctx.KVStore(k.storeKey) key := types.AuctionKey(denom) bz := store.Get(key) if bz == nil { - return types.Auction{}, fmt.Errorf("auction not found for denom '%s'", denom) + return &types.Auction{}, fmt.Errorf("auction not found for denom '%s'", denom) } var auction types.Auction if err := k.cdc.Unmarshal(bz, &auction); err != nil { - return types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.Denom, err) + return &types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.Denom, err) } - return auction, nil + return &auction, nil } // GetAllAuctions retrieves all stored auctions @@ -95,93 +95,12 @@ func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { return fmt.Errorf("cannot get auction for denom='%s': %w", bid.AuctionTokenDenom, err) } - // TODO check auction type and call handler - - // Get token amount being auctioned off - moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) - balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.Denom) - tokenAmountAvailable := balance.Amount - - // Verify auction has enough tokens to service the bid amount - if bid.AuctionTokenAmount.GT(tokenAmountAvailable) { - return fmt.Errorf("bid wants %s%s but auction has only %s%s", - bid.AuctionTokenAmount.String(), - auction.Denom, - tokenAmountAvailable.String(), - auction.Denom, - ) + // Get the appropriate auctionBidHandler for the auction type + auctionBidHandler, exists := bidHandlers[auction.Type] + if !exists { + return fmt.Errorf("unsupported auction type: %s", auction.Type) } - paymentTokenDenom := "ustrd" // TODO fix - - price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.Denom, paymentTokenDenom) - if err != nil { - } - - discountedPrice := price.Mul(auction.PriceMultiplier) - - if bid.AuctionTokenAmount.ToLegacyDec(). - Mul(discountedPrice). - LT(bid.PaymentTokenAmount.ToLegacyDec()) { - return fmt.Errorf("bid price too low: offered %s%s for %s%s, minimum required is %s%s (price=%s %s/%s)", - bid.PaymentTokenAmount.String(), - paymentTokenDenom, - bid.AuctionTokenAmount.String(), - auction.Denom, - bid.AuctionTokenAmount.ToLegacyDec().Mul(discountedPrice).String(), - paymentTokenDenom, - discountedPrice.String(), - paymentTokenDenom, - auction.Denom, - ) - } - - // Execute the exchange - - // Safe to use MustAccAddressFromBech32 because bid.Bidder passed ValidateBasic - bidder := sdk.MustAccAddressFromBech32(bid.Bidder) - - // Send paymentToken to beneficiary - // TODO move this up to fail early if not enought funds? - err = k.bankKeeper.SendCoins( - ctx, - bidder, - sdk.MustAccAddressFromBech32(auction.Beneficiary), - sdk.NewCoins(sdk.NewCoin(paymentTokenDenom, bid.PaymentTokenAmount)), - ) - if err != nil { - return fmt.Errorf("failed to send payment tokens from bidder '%s' to beneficiary '%s': %w", - bid.Bidder, - auction.Beneficiary, - err, - ) - } - - // Send auctionToken to bidder - // TODO move this up to fail early if not enought funds? - err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, - types.ModuleName, - bidder, - sdk.NewCoins(sdk.NewCoin(auction.Denom, bid.AuctionTokenAmount)), - ) - if err != nil { - return fmt.Errorf("failed to send auction tokens from module '%s' to bidder '%s': %w", - types.ModuleName, - bid.Bidder, - err, - ) - } - - auction.TotalTokensSold = auction.TotalTokensSold.Add(bid.AuctionTokenAmount) - auction.TotalStrdBurned = auction.TotalStrdBurned.Add(bid.PaymentTokenAmount) - - err = k.SetAuction(ctx, auction) - if err != nil { - return fmt.Errorf("failed to update auction stats") - } - - // TODO emit event - - return nil + // Call the handler + return auctionBidHandler(ctx, k, auction, bid) } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index f44e1dec03..28ffa69513 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -52,7 +52,7 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc Beneficiary: msg.Beneficiary, } - err = ms.Keeper.SetAuction(ctx, auction) + err = ms.Keeper.SetAuction(ctx, &auction) if err != nil { return nil, err } diff --git a/x/auction/keeper/query.go b/x/auction/keeper/query.go index ab5c0f95b3..6482971633 100644 --- a/x/auction/keeper/query.go +++ b/x/auction/keeper/query.go @@ -27,7 +27,7 @@ func (k Keeper) Auction(goCtx context.Context, req *types.QueryAuctionRequest) ( } return &types.QueryAuctionResponse{ - Auction: auction, + Auction: *auction, }, nil } From 59b2646c5e16dda10d61ba81512ff56e97506514 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Fri, 13 Dec 2024 16:37:19 +0200 Subject: [PATCH 021/115] icqoracle: add TokenPriceForQuoteDenom to grpc query service --- proto/stride/icqoracle/query.proto | 28 +- x/icqoracle/keeper/query.go | 18 + x/icqoracle/types/query.pb.go | 505 +++++++++++++++++++++++++++-- x/icqoracle/types/query.pb.gw.go | 89 ++++- 4 files changed, 599 insertions(+), 41 deletions(-) diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index 3cab7f6aed..ffaa219810 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -12,17 +12,23 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Query { // TokenPrice queries the current price for a specific token rpc TokenPrice(QueryTokenPriceRequest) returns (QueryTokenPriceResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/price"; + option (google.api.http).get = "/icqoracle/v1beta1/price"; } // TokenPrices queries all token prices rpc TokenPrices(QueryTokenPricesRequest) returns (QueryTokenPricesResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/prices"; + option (google.api.http).get = "/icqoracle/v1beta1/prices"; } // Params queries the oracle parameters rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/params"; + option (google.api.http).get = "/icqoracle/v1beta1/params"; + } + + // TokenPriceForQuoteDenom queries the exchange rate between two tokens + rpc TokenPriceForQuoteDenom(QueryTokenPriceForQuoteDenomRequest) + returns (QueryTokenPriceForQuoteDenomResponse) { + option (google.api.http).get = "/icqoracle/v1beta1/quote_price"; } } @@ -59,4 +65,20 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method message QueryParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryTokenPriceForQuoteDenomRequest is the request type for the +// Query/TokenPriceForQuoteDenom RPC method +message QueryTokenPriceForQuoteDenomRequest { + string base_denom = 1; + string quote_denom = 2; +} + +// QueryTokenPriceForQuoteDenomResponse is the response type for the +// Query/TokenPriceForQuoteDenom RPC method +message QueryTokenPriceForQuoteDenomResponse { + string price = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index 395e1efc69..b480dc7505 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -64,3 +64,21 @@ func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*t Params: params, }, nil } + +// TokenPriceForQuoteDenom queries the exchange rate between two tokens +func (k Keeper) TokenPriceForQuoteDenom(goCtx context.Context, req *types.QueryTokenPriceForQuoteDenomRequest) (*types.QueryTokenPriceForQuoteDenomResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + price, err := k.GetTokenPriceForQuoteDenom(ctx, req.BaseDenom, req.QuoteDenom) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + return &types.QueryTokenPriceForQuoteDenomResponse{ + Price: price, + }, nil +} diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 140a918d6e..9ba0f89524 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -320,6 +321,99 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryTokenPriceForQuoteDenomRequest is the request type for the +// Query/TokenPriceForQuoteDenom RPC method +type QueryTokenPriceForQuoteDenomRequest struct { + BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` +} + +func (m *QueryTokenPriceForQuoteDenomRequest) Reset() { *m = QueryTokenPriceForQuoteDenomRequest{} } +func (m *QueryTokenPriceForQuoteDenomRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTokenPriceForQuoteDenomRequest) ProtoMessage() {} +func (*QueryTokenPriceForQuoteDenomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{6} +} +func (m *QueryTokenPriceForQuoteDenomRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTokenPriceForQuoteDenomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTokenPriceForQuoteDenomRequest.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 *QueryTokenPriceForQuoteDenomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTokenPriceForQuoteDenomRequest.Merge(m, src) +} +func (m *QueryTokenPriceForQuoteDenomRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTokenPriceForQuoteDenomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTokenPriceForQuoteDenomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTokenPriceForQuoteDenomRequest proto.InternalMessageInfo + +func (m *QueryTokenPriceForQuoteDenomRequest) GetBaseDenom() string { + if m != nil { + return m.BaseDenom + } + return "" +} + +func (m *QueryTokenPriceForQuoteDenomRequest) GetQuoteDenom() string { + if m != nil { + return m.QuoteDenom + } + return "" +} + +// QueryTokenPriceForQuoteDenomResponse is the response type for the +// Query/TokenPriceForQuoteDenom RPC method +type QueryTokenPriceForQuoteDenomResponse struct { + Price github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"` +} + +func (m *QueryTokenPriceForQuoteDenomResponse) Reset() { *m = QueryTokenPriceForQuoteDenomResponse{} } +func (m *QueryTokenPriceForQuoteDenomResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTokenPriceForQuoteDenomResponse) ProtoMessage() {} +func (*QueryTokenPriceForQuoteDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{7} +} +func (m *QueryTokenPriceForQuoteDenomResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTokenPriceForQuoteDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTokenPriceForQuoteDenomResponse.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 *QueryTokenPriceForQuoteDenomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTokenPriceForQuoteDenomResponse.Merge(m, src) +} +func (m *QueryTokenPriceForQuoteDenomResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTokenPriceForQuoteDenomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTokenPriceForQuoteDenomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTokenPriceForQuoteDenomResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryTokenPriceRequest)(nil), "stride.icqoracle.QueryTokenPriceRequest") proto.RegisterType((*QueryTokenPriceResponse)(nil), "stride.icqoracle.QueryTokenPriceResponse") @@ -327,46 +421,53 @@ func init() { proto.RegisterType((*QueryTokenPricesResponse)(nil), "stride.icqoracle.QueryTokenPricesResponse") proto.RegisterType((*QueryParamsRequest)(nil), "stride.icqoracle.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "stride.icqoracle.QueryParamsResponse") + proto.RegisterType((*QueryTokenPriceForQuoteDenomRequest)(nil), "stride.icqoracle.QueryTokenPriceForQuoteDenomRequest") + proto.RegisterType((*QueryTokenPriceForQuoteDenomResponse)(nil), "stride.icqoracle.QueryTokenPriceForQuoteDenomResponse") } func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x8b, 0xd3, 0x40, - 0x18, 0x6e, 0xb6, 0x5a, 0xd9, 0x37, 0x1e, 0x64, 0x5c, 0xdc, 0x10, 0x6a, 0x5a, 0x83, 0xba, 0x75, - 0xc1, 0x0c, 0xdb, 0x15, 0x7f, 0x80, 0x9f, 0x08, 0x2e, 0xd4, 0xea, 0xc9, 0x83, 0x65, 0x92, 0x0e, - 0x31, 0xd8, 0x66, 0x92, 0xcc, 0x74, 0x71, 0x4f, 0x82, 0x47, 0x0f, 0x22, 0xf8, 0x1f, 0x3c, 0xf8, - 0x4b, 0xf6, 0xb8, 0xe0, 0xc5, 0x93, 0x48, 0xeb, 0x0f, 0x91, 0xf9, 0x48, 0x3f, 0x8c, 0xd2, 0x7a, - 0x9b, 0x3e, 0xef, 0x33, 0xcf, 0xfb, 0xbc, 0xcf, 0x3b, 0x0d, 0x34, 0xb9, 0x28, 0x92, 0x21, 0xc5, - 0x49, 0x94, 0xb3, 0x82, 0x44, 0x23, 0x8a, 0xf3, 0x09, 0x2d, 0x4e, 0x82, 0xac, 0x60, 0x82, 0xa1, - 0x4b, 0xba, 0x1a, 0xcc, 0xab, 0x6e, 0xbb, 0xc2, 0x9f, 0x9f, 0xf4, 0x1d, 0x77, 0x27, 0x66, 0x31, - 0x53, 0x47, 0x2c, 0x4f, 0x06, 0x6d, 0xc6, 0x8c, 0xc5, 0x23, 0x8a, 0x49, 0x96, 0x60, 0x92, 0xa6, - 0x4c, 0x10, 0x91, 0xb0, 0x94, 0x9b, 0xea, 0x7e, 0xc4, 0xf8, 0x98, 0x71, 0x1c, 0x12, 0x6e, 0x0c, - 0xe0, 0xe3, 0x83, 0x90, 0x0a, 0x72, 0x80, 0x33, 0x12, 0x27, 0xa9, 0x22, 0x6b, 0xae, 0x9f, 0xc3, - 0x95, 0x67, 0x92, 0xf1, 0x82, 0xbd, 0xa1, 0x69, 0xaf, 0x48, 0x22, 0xda, 0xa7, 0xf9, 0x84, 0x72, - 0x81, 0xae, 0x02, 0x48, 0x81, 0xc1, 0x90, 0xa6, 0x6c, 0xec, 0x58, 0x6d, 0xab, 0xb3, 0xdd, 0xdf, - 0x96, 0xc8, 0x03, 0x09, 0xa0, 0x16, 0xd8, 0xf9, 0x84, 0x89, 0xb2, 0xbe, 0xa5, 0xea, 0xa0, 0x20, - 0x4d, 0xd8, 0x85, 0x0b, 0x19, 0x63, 0xa3, 0x41, 0x32, 0x74, 0xea, 0xaa, 0xd8, 0x90, 0x3f, 0x9f, - 0x0c, 0xfd, 0x57, 0xb0, 0x5b, 0x69, 0xc9, 0x33, 0x96, 0x72, 0x8a, 0xee, 0x83, 0x2d, 0x24, 0x3a, - 0xc8, 0x24, 0xac, 0x9a, 0xda, 0xdd, 0x66, 0xf0, 0x67, 0x6e, 0xc1, 0xe2, 0xea, 0xbd, 0x73, 0xa7, - 0x3f, 0x5a, 0xb5, 0x3e, 0x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0xa0, 0xd7, 0x76, 0x74, 0x3a, - 0xf5, 0xac, 0xb3, 0xa9, 0x67, 0xfd, 0x9c, 0x7a, 0xd6, 0xa7, 0x99, 0x57, 0x3b, 0x9b, 0x79, 0xb5, - 0xef, 0x33, 0xaf, 0xf6, 0xf2, 0x30, 0x4e, 0xc4, 0xeb, 0x49, 0x18, 0x44, 0x6c, 0x8c, 0x9f, 0x2b, - 0x95, 0xdb, 0x4f, 0x49, 0xc8, 0x4b, 0xc5, 0xe3, 0xee, 0x1d, 0xfc, 0x76, 0x49, 0x57, 0x9c, 0x64, - 0x94, 0x87, 0x0d, 0xf5, 0x19, 0x39, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xe5, 0xea, 0x8a, 0x44, - 0xfa, 0x04, 0x00, 0x00, + // 624 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4d, 0x6f, 0x12, 0x41, + 0x18, 0xc7, 0xd9, 0xbe, 0x60, 0xfa, 0xe0, 0xc1, 0x8c, 0x8d, 0x5d, 0x57, 0x5c, 0x70, 0xad, 0x58, + 0x9b, 0x74, 0x27, 0xa5, 0xda, 0x0f, 0x80, 0x58, 0x63, 0x62, 0x13, 0x8a, 0x9e, 0x3c, 0x48, 0x86, + 0x65, 0xb2, 0x6e, 0x0a, 0x3b, 0xcb, 0xce, 0xd2, 0xb4, 0x57, 0x3d, 0x78, 0x35, 0xf1, 0x5b, 0x78, + 0xf2, 0x43, 0x78, 0xe8, 0xb1, 0x89, 0x17, 0xe3, 0xa1, 0x31, 0xe0, 0x07, 0x31, 0x3b, 0x33, 0xc0, + 0xd2, 0x05, 0xc1, 0xc4, 0x53, 0xa7, 0xcf, 0xeb, 0xef, 0x79, 0xe6, 0x3f, 0x0b, 0xe4, 0x79, 0x14, + 0x7a, 0x2d, 0x8a, 0x3d, 0xa7, 0xcb, 0x42, 0xe2, 0xb4, 0x29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 0xdf, 0x7f, 0xff, 0xfd, 0x79, 0xc9, 0x40, 0x7a, 0xe2, 0x73, + 0x30, 0x7a, 0xb7, 0xa2, 0xed, 0x47, 0x0d, 0x72, 0x09, 0xc5, 0xa1, 0xf9, 0xc5, 0x87, 0xd7, 0x6d, + 0x6c, 0x2f, 0x12, 0xaa, 0x40, 0xee, 0x09, 0x90, 0x3b, 0xe8, 0xf6, 0x2c, 0x10, 0x8e, 0x4e, 0x21, + 0x2b, 0x65, 0x80, 0x36, 0x67, 0x14, 0x9e, 0x50, 0x9b, 0xf1, 0x60, 0x4e, 0xd4, 0x22, 0x9d, 0x65, + 0xbf, 0xaf, 0x1a, 0x6c, 0xcc, 0xb8, 0x7d, 0xf4, 0x64, 0xee, 0x90, 0xd3, 0x44, 0x69, 0xec, 0xff, + 0x6b, 0x9a, 0xa2, 0x2d, 0x09, 0xda, 0x22, 0x32, 0xa7, 0xd0, 0x4a, 0x19, 0x8b, 0x6d, 0x55, 0x0e, + 0xcf, 0xfb, 0xa6, 0x76, 0xd1, 0x37, 0xb5, 0x5f, 0x7d, 0x53, 0xfb, 0x34, 0x30, 0x33, 0x17, 0x03, + 0x33, 0xf3, 0x63, 0x60, 0x66, 0xde, 0xec, 0x25, 0xf4, 0xf8, 0x4a, 0x30, 0xec, 0xbc, 0x24, 0x4d, + 0x8e, 0xd5, 0xcf, 0xc2, 0x49, 0xf9, 0x31, 0x3e, 0x4d, 0x14, 0x17, 0x02, 0x6d, 0x66, 0xc5, 0x97, + 0x7b, 0xef, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0xc9, 0x64, 0xa4, 0x6d, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -387,6 +488,8 @@ type QueryClient interface { TokenPrices(ctx context.Context, in *QueryTokenPricesRequest, opts ...grpc.CallOption) (*QueryTokenPricesResponse, error) // Params queries the oracle parameters Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // TokenPriceForQuoteDenom queries the exchange rate between two tokens + TokenPriceForQuoteDenom(ctx context.Context, in *QueryTokenPriceForQuoteDenomRequest, opts ...grpc.CallOption) (*QueryTokenPriceForQuoteDenomResponse, error) } type queryClient struct { @@ -424,6 +527,15 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) TokenPriceForQuoteDenom(ctx context.Context, in *QueryTokenPriceForQuoteDenomRequest, opts ...grpc.CallOption) (*QueryTokenPriceForQuoteDenomResponse, error) { + out := new(QueryTokenPriceForQuoteDenomResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Query/TokenPriceForQuoteDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // TokenPrice queries the current price for a specific token @@ -432,6 +544,8 @@ type QueryServer interface { TokenPrices(context.Context, *QueryTokenPricesRequest) (*QueryTokenPricesResponse, error) // Params queries the oracle parameters Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // TokenPriceForQuoteDenom queries the exchange rate between two tokens + TokenPriceForQuoteDenom(context.Context, *QueryTokenPriceForQuoteDenomRequest) (*QueryTokenPriceForQuoteDenomResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -447,6 +561,9 @@ func (*UnimplementedQueryServer) TokenPrices(ctx context.Context, req *QueryToke func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) TokenPriceForQuoteDenom(ctx context.Context, req *QueryTokenPriceForQuoteDenomRequest) (*QueryTokenPriceForQuoteDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TokenPriceForQuoteDenom not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -506,6 +623,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_TokenPriceForQuoteDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTokenPriceForQuoteDenomRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TokenPriceForQuoteDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.icqoracle.Query/TokenPriceForQuoteDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TokenPriceForQuoteDenom(ctx, req.(*QueryTokenPriceForQuoteDenomRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "stride.icqoracle.Query", HandlerType: (*QueryServer)(nil), @@ -522,6 +657,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "TokenPriceForQuoteDenom", + Handler: _Query_TokenPriceForQuoteDenom_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "stride/icqoracle/query.proto", @@ -744,6 +883,76 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryTokenPriceForQuoteDenomRequest) 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 *QueryTokenPriceForQuoteDenomRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTokenPriceForQuoteDenomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.QuoteDenom) > 0 { + i -= len(m.QuoteDenom) + copy(dAtA[i:], m.QuoteDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTokenPriceForQuoteDenomResponse) 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 *QueryTokenPriceForQuoteDenomResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTokenPriceForQuoteDenomResponse) 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] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -839,6 +1048,34 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryTokenPriceForQuoteDenomRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BaseDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTokenPriceForQuoteDenomResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = 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 } @@ -1413,6 +1650,204 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTokenPriceForQuoteDenomRequest) 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: QueryTokenPriceForQuoteDenomRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTokenPriceForQuoteDenomRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", 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.BaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", 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.QuoteDenom = string(dAtA[iNdEx:postIndex]) + 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 *QueryTokenPriceForQuoteDenomResponse) 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: QueryTokenPriceForQuoteDenomResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTokenPriceForQuoteDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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/icqoracle/types/query.pb.gw.go b/x/icqoracle/types/query.pb.gw.go index 2f763bde64..368423edc4 100644 --- a/x/icqoracle/types/query.pb.gw.go +++ b/x/icqoracle/types/query.pb.gw.go @@ -123,6 +123,42 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_TokenPriceForQuoteDenom_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_TokenPriceForQuoteDenom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTokenPriceForQuoteDenomRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TokenPriceForQuoteDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TokenPriceForQuoteDenom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TokenPriceForQuoteDenom_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTokenPriceForQuoteDenomRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TokenPriceForQuoteDenom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TokenPriceForQuoteDenom(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -198,6 +234,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TokenPriceForQuoteDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TokenPriceForQuoteDenom_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TokenPriceForQuoteDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -299,15 +358,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TokenPriceForQuoteDenom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TokenPriceForQuoteDenom_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TokenPriceForQuoteDenom_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "price"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "price"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_TokenPriceForQuoteDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "quote_price"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -316,4 +397,6 @@ var ( forward_Query_TokenPrices_0 = runtime.ForwardResponseMessage forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_TokenPriceForQuoteDenom_0 = runtime.ForwardResponseMessage ) From d487cbd8b8272cd24836ffcf79af641b425793af Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Fri, 13 Dec 2024 17:19:40 +0200 Subject: [PATCH 022/115] implement module boilerpalte for auction and icqoracle --- x/auction/module.go | 22 +++++++++------------ x/auction/types/genesis.go | 39 ++++++++++++++++++++++++++++++++++++-- x/auction/types/msgs.go | 12 ++++++------ x/icqoracle/module.go | 22 +++++++++------------ 4 files changed, 61 insertions(+), 34 deletions(-) diff --git a/x/auction/module.go b/x/auction/module.go index c217b4d36a..95244872ef 100644 --- a/x/auction/module.go +++ b/x/auction/module.go @@ -1,6 +1,7 @@ package auction import ( + "context" "encoding/json" "fmt" @@ -16,6 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/Stride-Labs/stride/v24/x/auction/client/cli" "github.com/Stride-Labs/stride/v24/x/auction/keeper" "github.com/Stride-Labs/stride/v24/x/auction/types" ) @@ -72,24 +74,19 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // TODO: Queries - // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - // panic(err) - // } + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. func (a AppModuleBasic) GetTxCmd() *cobra.Command { - // TODO: messages - // return cli.GetTxCmd() - return nil + return cli.GetTxCmd() } // GetQueryCmd returns the capability module's root query command. func (AppModuleBasic) GetQueryCmd() *cobra.Command { - // TODO: Queries - // return cli.GetQueryCmd() - return nil + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- @@ -121,9 +118,8 @@ func (am AppModule) Name() string { // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - // TODO: Queries and Messages - // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } // RegisterInvariants registers the capability module's invariants. diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go index 8837ec5300..b52d1807e0 100644 --- a/x/auction/types/genesis.go +++ b/x/auction/types/genesis.go @@ -1,12 +1,47 @@ package types +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{} } -// Performs basic genesis state validation +// ZeroAddress is a valid 20 byte canonical address (all zeros) used as a placeholder address +// during genesis validation. We need this because MsgCreateAuction requires an admin address +// parameter, but during genesis validation we only care about validating the auction parameters +// themselves, not the admin who created them. Using a zero address allows us to validate auction +// properties without needing a real cryptographic address, while still maintaining compatibility +// with the MsgCreateAuction validation logic. +var ZeroAddress = sdk.AccAddress{ + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +} + +// Performs basic genesis state validation by iterating through all auctions and validating +// using ValidateBasic() since it already implements thorough validation of all auction fields func (gs GenesisState) Validate() error { - // TODO: ??? + for i, auction := range gs.Auctions { + + msg := NewMsgCreateAuction( + ZeroAddress.String(), + auction.Type, + auction.Denom, + auction.Enabled, + auction.PriceMultiplier.String(), + auction.MinBidAmount.Uint64(), + auction.Beneficiary, + ) + + if err := msg.ValidateBasic(); err != nil { + return fmt.Errorf("invalid genesis auction at index %d: %s", i, err.Error()) + } + } return nil } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index cc0d5d54f5..313601eecb 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -136,22 +136,22 @@ func (msg *MsgCreateAuction) GetSignBytes() []byte { func (msg *MsgCreateAuction) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid admin address (%s)", err) } if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { - return errors.New("auction-type is invalid") + return fmt.Errorf("auction-type %d is invalid", msg.AuctionType) } if msg.Denom == "" { return errors.New("denom must be specified") } if msg.MinBidAmount.LT(math.ZeroInt()) { - return errors.New("min-bid-amount must be at least 0") + return errors.New("min-bid-amount must be >= 0") } - if msg.PriceMultiplier.IsZero() { - return errors.New("price-multiplier cannot be 0") + if !(msg.PriceMultiplier.GT(math.LegacyZeroDec()) && msg.PriceMultiplier.LTE(math.LegacyOneDec())) { + return errors.New("price-multiplier must be > 0 and <= 1 (0 > priceMultiplier >= 1)") } if _, err := sdk.AccAddressFromBech32(msg.Beneficiary); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid beneficiary address (%s)", err) } return nil diff --git a/x/icqoracle/module.go b/x/icqoracle/module.go index 3a22d5ded0..d7102d32fc 100644 --- a/x/icqoracle/module.go +++ b/x/icqoracle/module.go @@ -1,6 +1,7 @@ package icqoracle import ( + "context" "encoding/json" "fmt" @@ -16,6 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/Stride-Labs/stride/v24/x/icqoracle/client/cli" "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) @@ -72,24 +74,19 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // TODO: Queries - // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - // panic(err) - // } + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. func (a AppModuleBasic) GetTxCmd() *cobra.Command { - // TODO: messages - // return cli.GetTxCmd() - return nil + return cli.GetTxCmd() } // GetQueryCmd returns the capability module's root query command. func (AppModuleBasic) GetQueryCmd() *cobra.Command { - // TODO: Queries - // return cli.GetQueryCmd() - return nil + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- @@ -121,9 +118,8 @@ func (am AppModule) Name() string { // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - // TODO: Queries and Messages - // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } // RegisterInvariants registers the capability module's invariants. From d1724efc4c17339a54a6f331eea18e34290fce90 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Fri, 13 Dec 2024 22:32:31 +0200 Subject: [PATCH 023/115] genesis stuff --- x/auction/types/genesis.go | 19 ++----------------- x/icqoracle/keeper/genesis.go | 7 +++++++ x/icqoracle/keeper/keeper.go | 11 ++++++++++- x/icqoracle/types/genesis.go | 25 +++++++++++++++++++++++-- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go index b52d1807e0..4b8d1f6bb3 100644 --- a/x/auction/types/genesis.go +++ b/x/auction/types/genesis.go @@ -2,8 +2,6 @@ package types import ( "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultGenesis returns the default genesis state @@ -11,26 +9,13 @@ func DefaultGenesis() *GenesisState { return &GenesisState{} } -// ZeroAddress is a valid 20 byte canonical address (all zeros) used as a placeholder address -// during genesis validation. We need this because MsgCreateAuction requires an admin address -// parameter, but during genesis validation we only care about validating the auction parameters -// themselves, not the admin who created them. Using a zero address allows us to validate auction -// properties without needing a real cryptographic address, while still maintaining compatibility -// with the MsgCreateAuction validation logic. -var ZeroAddress = sdk.AccAddress{ - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -} - // Performs basic genesis state validation by iterating through all auctions and validating // using ValidateBasic() since it already implements thorough validation of all auction fields func (gs GenesisState) Validate() error { for i, auction := range gs.Auctions { msg := NewMsgCreateAuction( - ZeroAddress.String(), + "stride16eenchewedupsplt0ut600ed0ffstageeeervs", // dummy address, not stored in auction auction.Type, auction.Denom, auction.Enabled, @@ -40,7 +25,7 @@ func (gs GenesisState) Validate() error { ) if err := msg.ValidateBasic(); err != nil { - return fmt.Errorf("invalid genesis auction at index %d: %s", i, err.Error()) + return fmt.Errorf("invalid genesis auction at index %d: %w", i, err) } } return nil diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go index c742a9e5cf..6e0961aa03 100644 --- a/x/icqoracle/keeper/genesis.go +++ b/x/icqoracle/keeper/genesis.go @@ -1,6 +1,9 @@ package keeper import ( + "time" + + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Stride-Labs/stride/v24/x/icqoracle/types" @@ -10,6 +13,10 @@ import ( func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { k.SetParams(ctx, genState.Params) for _, tokenPrice := range genState.TokenPrices { + tokenPrice.SpotPrice = math.LegacyZeroDec() + tokenPrice.UpdatedAt = time.Time{} + tokenPrice.QueryInProgress = false + if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { panic(err) } diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 421d45fa4d..428e3a1773 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -189,6 +189,7 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu foundCommonQuoteToken := false foundBaseTokenStalePrice := false foundQuoteTokenStalePrice := false + foundQuoteTokenZeroPrice := false // Find a common quote denom and calculate baseToken to quoteToken price for quoteDenom1, baseTokenPrice := range baseTokenPrices { @@ -206,6 +207,13 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu continue } + // Check that quote price is not zero to prevent division by zero + + if quoteTokenPrice.SpotPrice.IsZero() { + foundQuoteTokenZeroPrice = true + continue + } + // Calculate the price of 1 baseToken in quoteToken price = baseTokenPrice.SpotPrice.Quo(quoteTokenPrice.SpotPrice) @@ -216,12 +224,13 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu if price.IsZero() { return math.LegacyDec{}, fmt.Errorf( - "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v')", + "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v', foundQuoteTokenZeroPrice='%v')", baseDenom, quoteDenom, foundCommonQuoteToken, foundBaseTokenStalePrice, foundQuoteTokenStalePrice, + foundQuoteTokenZeroPrice, ) } diff --git a/x/icqoracle/types/genesis.go b/x/icqoracle/types/genesis.go index 8837ec5300..e6a15be5a9 100644 --- a/x/icqoracle/types/genesis.go +++ b/x/icqoracle/types/genesis.go @@ -1,12 +1,33 @@ package types +import ( + fmt "fmt" +) + // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{} } -// Performs basic genesis state validation +// Performs basic genesis state validation by iterating through all token prices and validating +// using ValidateBasic() since it already implements thorough validation of the important token +// price fields. +// We ignore the SpotPrice, UpdatedAt & QueryInProgress fields since they are reset in InitGenesis(). func (gs GenesisState) Validate() error { - // TODO: ??? + for i, tokenPrice := range gs.TokenPrices { + + msg := NewMsgAddTokenPrice( + "stride1palmssweatykneesweakarmsareheavy8ahm9u", // dummy address, not stored in token price + tokenPrice.BaseDenom, + tokenPrice.QuoteDenom, + tokenPrice.OsmosisPoolId, + tokenPrice.OsmosisBaseDenom, + tokenPrice.OsmosisQuoteDenom, + ) + + if err := msg.ValidateBasic(); err != nil { + return fmt.Errorf("invalid genesis token price at index %d: %w", i, err) + } + } return nil } From a740fa3a7dfa729ac5a1c39dcb1aa714cfc7b790 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:21:23 +0200 Subject: [PATCH 024/115] icqoracle: remove unnecessary expected keepers --- app/app.go | 2 -- x/icqoracle/keeper/keeper.go | 16 +++++----------- x/icqoracle/types/expected_keepers.go | 21 --------------------- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/app/app.go b/app/app.go index 292b434443..67e8be83a3 100644 --- a/app/app.go +++ b/app/app.go @@ -767,8 +767,6 @@ func NewStrideApp( app.ICQOracleKeeper = *icqoraclekeeper.NewKeeper( appCodec, keys[icqoracletypes.StoreKey], - app.BankKeeper, - app.TransferKeeper, ) icqOracleModule := icqoracle.NewAppModule(appCodec, app.ICQOracleKeeper) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index faf00b740c..44df0d77f6 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -17,24 +17,18 @@ import ( ) type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - bankKeeper types.BankKeeper - transferKeeper types.TransferKeeper - icqKeeper interchainquerykeeper.Keeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + icqKeeper interchainquerykeeper.Keeper } func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - bankKeeper types.BankKeeper, - transferKeeper types.TransferKeeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - bankKeeper: bankKeeper, - transferKeeper: transferKeeper, + cdc: cdc, + storeKey: storeKey, } } diff --git a/x/icqoracle/types/expected_keepers.go b/x/icqoracle/types/expected_keepers.go index 6d2b52961e..ab1254f4c2 100644 --- a/x/icqoracle/types/expected_keepers.go +++ b/x/icqoracle/types/expected_keepers.go @@ -1,22 +1 @@ package types - -import ( - context "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" -) - -// Required BankKeeper functions -type BankKeeper interface { - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - GetSupply(ctx sdk.Context, denom string) sdk.Coin - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error -} - -// Required TransferKeeper functions -type TransferKeeper interface { - Transfer(goCtx context.Context, msg *transfertypes.MsgTransfer) (*transfertypes.MsgTransferResponse, error) -} From 40c49711e2f1ad1b56bb5c2a4e33375460f853d4 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:25:49 +0200 Subject: [PATCH 025/115] Simplifies ICQ oracle API endpoint paths Removes redundant 'stride' and 'v1beta1' segments from API paths to make them cleaner and more consistent - /icqoracle/price - /icqoracle/prices - /icqoracle/params --- proto/stride/icqoracle/query.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index 3cab7f6aed..b355399498 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -12,17 +12,17 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Query { // TokenPrice queries the current price for a specific token rpc TokenPrice(QueryTokenPriceRequest) returns (QueryTokenPriceResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/price"; + option (google.api.http).get = "/icqoracle/price"; } // TokenPrices queries all token prices rpc TokenPrices(QueryTokenPricesRequest) returns (QueryTokenPricesResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/prices"; + option (google.api.http).get = "/icqoracle/prices"; } // Params queries the oracle parameters rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/stride/icqoracle/v1beta1/params"; + option (google.api.http).get = "/icqoracle/params"; } } From 60b2cf0e35390bd02b1bde8ae9d76db2685015f9 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:35:11 +0200 Subject: [PATCH 026/115] s/MsgAddTokenPrice/MsgRegisterTokenPriceQuery/g --- proto/stride/icqoracle/tx.proto | 14 ++- x/icqoracle/client/cli/tx.go | 4 +- x/icqoracle/keeper/msg_server.go | 6 +- x/icqoracle/types/codec.go | 4 +- x/icqoracle/types/msgs.go | 24 ++-- x/icqoracle/types/query.pb.go | 70 +++++------ x/icqoracle/types/query.pb.gw.go | 6 +- x/icqoracle/types/tx.pb.go | 196 ++++++++++++++++--------------- 8 files changed, 164 insertions(+), 160 deletions(-) diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index bba1684b00..6c838a905c 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -11,18 +11,20 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Msg { option (cosmos.msg.v1.service) = true; - // AddTokenPrice adds a new token to track prices for - rpc AddTokenPrice(MsgAddTokenPrice) returns (MsgAddTokenPriceResponse); + // RegisterTokenPriceQuery registers a new token to track prices for + rpc RegisterTokenPriceQuery(MsgRegisterTokenPriceQuery) + returns (MsgRegisterTokenPriceQueryResponse); // RemoveTokenPrice removes a token from price tracking rpc RemoveTokenPrice(MsgRemoveTokenPrice) returns (MsgRemoveTokenPriceResponse); } -// MsgAddTokenPrice defines the message for adding a new token to track prices -message MsgAddTokenPrice { +// MsgRegisterTokenPriceQuery defines the message for adding a new token to +// track prices +message MsgRegisterTokenPriceQuery { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "stride/x/icqoracle/MsgAddTokenPrice"; + option (amino.name) = "stride/x/icqoracle/MsgRegisterTokenPriceQuery"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; @@ -38,7 +40,7 @@ message MsgAddTokenPrice { string osmosis_pool_id = 6; } -message MsgAddTokenPriceResponse {} +message MsgRegisterTokenPriceQueryResponse {} // MsgRemoveTokenPrice defines the message for removing a token from price // tracking diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go index 77e7073566..48fb9a0196 100644 --- a/x/icqoracle/client/cli/tx.go +++ b/x/icqoracle/client/cli/tx.go @@ -42,14 +42,14 @@ Example: $ %[1]s tx %[2]s add-token-price uosmo uatom 123 uosmo ibc/... --from admin `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - msg := types.NewMsgAddTokenPrice( + msg := types.NewMsgRegisterTokenPriceQuery( clientCtx.GetFromAddress().String(), args[0], args[1], diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index d60cca7c3d..b5045cd17c 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -22,8 +22,8 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { var _ types.MsgServer = msgServer{} -// AddTokenPrice adds a token to price tracking -func (ms msgServer) AddTokenPrice(goCtx context.Context, msg *types.MsgAddTokenPrice) (*types.MsgAddTokenPriceResponse, error) { +// RegisterTokenPriceQuery registers a token to price tracking +func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.MsgRegisterTokenPriceQuery) (*types.MsgRegisterTokenPriceQueryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // TODO check admin @@ -44,7 +44,7 @@ func (ms msgServer) AddTokenPrice(goCtx context.Context, msg *types.MsgAddTokenP return nil, err } - return &types.MsgAddTokenPriceResponse{}, nil + return &types.MsgRegisterTokenPriceQueryResponse{}, nil } // RemoveTokenPrice removes a token from price tracking diff --git a/x/icqoracle/types/codec.go b/x/icqoracle/types/codec.go index d2ad84ca6c..ebc9a0dc0a 100644 --- a/x/icqoracle/types/codec.go +++ b/x/icqoracle/types/codec.go @@ -11,13 +11,13 @@ import ( ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - legacy.RegisterAminoMsg(cdc, &MsgAddTokenPrice{}, "icqoracle/MsgAddTokenPrice") + legacy.RegisterAminoMsg(cdc, &MsgRegisterTokenPriceQuery{}, "icqoracle/MsgRegisterTokenPriceQuery") legacy.RegisterAminoMsg(cdc, &MsgRemoveTokenPrice{}, "icqoracle/MsgRemoveTokenPrice") } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgAddTokenPrice{}, + &MsgRegisterTokenPriceQuery{}, &MsgRemoveTokenPrice{}, ) diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 5037ec8b17..176bfe636d 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -11,16 +11,16 @@ import ( ) const ( - TypeMsgAddTokenPrice = "add_token_price" - TypeMsgRemoveTokenPrice = "remove_token_price" + TypeMsgRegisterTokenPriceQuery = "register_token_price_query" + TypeMsgRemoveTokenPrice = "remove_token_price" ) var ( - _ sdk.Msg = &MsgAddTokenPrice{} + _ sdk.Msg = &MsgRegisterTokenPriceQuery{} _ sdk.Msg = &MsgRemoveTokenPrice{} // Implement legacy interface for ledger support - _ legacytx.LegacyMsg = &MsgAddTokenPrice{} + _ legacytx.LegacyMsg = &MsgRegisterTokenPriceQuery{} _ legacytx.LegacyMsg = &MsgRemoveTokenPrice{} ) @@ -28,8 +28,8 @@ var ( // MsgClaim // ---------------------------------------------- -func NewMsgAddTokenPrice(sender, baseDenom, quoteDenom, poolId, osmosisBaseDenom, osmosisQuoteDenom string) *MsgAddTokenPrice { - return &MsgAddTokenPrice{ +func NewMsgRegisterTokenPriceQuery(sender, baseDenom, quoteDenom, poolId, osmosisBaseDenom, osmosisQuoteDenom string) *MsgRegisterTokenPriceQuery { + return &MsgRegisterTokenPriceQuery{ Sender: sender, BaseDenom: baseDenom, QuoteDenom: quoteDenom, @@ -39,15 +39,15 @@ func NewMsgAddTokenPrice(sender, baseDenom, quoteDenom, poolId, osmosisBaseDenom } } -func (msg MsgAddTokenPrice) Type() string { - return TypeMsgAddTokenPrice +func (msg MsgRegisterTokenPriceQuery) Type() string { + return TypeMsgRegisterTokenPriceQuery } -func (msg MsgAddTokenPrice) Route() string { +func (msg MsgRegisterTokenPriceQuery) Route() string { return RouterKey } -func (msg *MsgAddTokenPrice) GetSigners() []sdk.AccAddress { +func (msg *MsgRegisterTokenPriceQuery) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { panic(err) @@ -55,12 +55,12 @@ func (msg *MsgAddTokenPrice) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } -func (msg *MsgAddTokenPrice) GetSignBytes() []byte { +func (msg *MsgRegisterTokenPriceQuery) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgAddTokenPrice) ValidateBasic() error { +func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 140a918d6e..95779c3e38 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -332,41 +332,41 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x8b, 0xd3, 0x40, - 0x18, 0x6e, 0xb6, 0x5a, 0xd9, 0x37, 0x1e, 0x64, 0x5c, 0xdc, 0x10, 0x6a, 0x5a, 0x83, 0xba, 0x75, - 0xc1, 0x0c, 0xdb, 0x15, 0x7f, 0x80, 0x9f, 0x08, 0x2e, 0xd4, 0xea, 0xc9, 0x83, 0x65, 0x92, 0x0e, - 0x31, 0xd8, 0x66, 0x92, 0xcc, 0x74, 0x71, 0x4f, 0x82, 0x47, 0x0f, 0x22, 0xf8, 0x1f, 0x3c, 0xf8, - 0x4b, 0xf6, 0xb8, 0xe0, 0xc5, 0x93, 0x48, 0xeb, 0x0f, 0x91, 0xf9, 0x48, 0x3f, 0x8c, 0xd2, 0x7a, - 0x9b, 0x3e, 0xef, 0x33, 0xcf, 0xfb, 0xbc, 0xcf, 0x3b, 0x0d, 0x34, 0xb9, 0x28, 0x92, 0x21, 0xc5, - 0x49, 0x94, 0xb3, 0x82, 0x44, 0x23, 0x8a, 0xf3, 0x09, 0x2d, 0x4e, 0x82, 0xac, 0x60, 0x82, 0xa1, - 0x4b, 0xba, 0x1a, 0xcc, 0xab, 0x6e, 0xbb, 0xc2, 0x9f, 0x9f, 0xf4, 0x1d, 0x77, 0x27, 0x66, 0x31, - 0x53, 0x47, 0x2c, 0x4f, 0x06, 0x6d, 0xc6, 0x8c, 0xc5, 0x23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xe3, 0xee, 0x1d, 0xfc, 0x76, 0x49, 0x57, 0x9c, 0x64, - 0x94, 0x87, 0x0d, 0xf5, 0x19, 0x39, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xe5, 0xea, 0x8a, 0x44, - 0xfa, 0x04, 0x00, 0x00, + // 529 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x53, 0x08, 0xea, 0x35, 0x8b, 0x32, 0xad, 0xa8, 0xb1, 0x8a, 0x1b, 0x59, 0x3c, 0x4a, + 0x25, 0x3c, 0x6a, 0x8a, 0xf8, 0x00, 0x9e, 0x42, 0xa2, 0x52, 0x08, 0xac, 0x58, 0x10, 0x8d, 0x9d, + 0x91, 0xb1, 0x48, 0x3c, 0xb6, 0x67, 0x52, 0x51, 0xb1, 0x40, 0xe2, 0x0b, 0x90, 0xf8, 0x0b, 0xbe, + 0xa4, 0xcb, 0x4a, 0x6c, 0x58, 0x21, 0x94, 0xf0, 0x0f, 0x6c, 0xd1, 0x3c, 0x9c, 0x38, 0x35, 0x90, + 0xec, 0x26, 0xe7, 0x9e, 0x7b, 0xcf, 0xb9, 0x67, 0xe2, 0x81, 0x1d, 0x2e, 0x8a, 0x64, 0x40, 0x71, + 0x12, 0xe5, 0xac, 0x20, 0xd1, 0x90, 0xe2, 0x7c, 0x4c, 0x8b, 0x93, 0x20, 0x2b, 0x98, 0x60, 0x68, + 0x43, 0x57, 0x83, 0x59, 0xd5, 0x6d, 0xd7, 0xf8, 0xb3, 0x93, 0xee, 0x71, 0xb7, 0x62, 0x16, 0x33, + 0x75, 0xc4, 0xf2, 0x64, 0xd0, 0x9d, 0x98, 0xb1, 0x78, 0x48, 0x31, 0xc9, 0x12, 0x4c, 0xd2, 0x94, + 0x09, 0x22, 0x12, 0x96, 0x72, 0x53, 0xdd, 0x8f, 0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f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x90, 0x16, 0xc9, 0xcb, 0x04, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/icqoracle/types/query.pb.gw.go b/x/icqoracle/types/query.pb.gw.go index 2f763bde64..65cd7b072a 100644 --- a/x/icqoracle/types/query.pb.gw.go +++ b/x/icqoracle/types/query.pb.gw.go @@ -303,11 +303,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "price"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"icqoracle", "price"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"icqoracle", "prices"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"stride", "icqoracle", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"icqoracle", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index fa1140be1f..96ee5cec73 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -30,8 +30,9 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgAddTokenPrice defines the message for adding a new token to track prices -type MsgAddTokenPrice struct { +// MsgRegisterTokenPriceQuery defines the message for adding a new token to +// track prices +type MsgRegisterTokenPriceQuery struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` @@ -45,18 +46,18 @@ type MsgAddTokenPrice struct { OsmosisPoolId string `protobuf:"bytes,6,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } -func (m *MsgAddTokenPrice) Reset() { *m = MsgAddTokenPrice{} } -func (m *MsgAddTokenPrice) String() string { return proto.CompactTextString(m) } -func (*MsgAddTokenPrice) ProtoMessage() {} -func (*MsgAddTokenPrice) Descriptor() ([]byte, []int) { +func (m *MsgRegisterTokenPriceQuery) Reset() { *m = MsgRegisterTokenPriceQuery{} } +func (m *MsgRegisterTokenPriceQuery) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterTokenPriceQuery) ProtoMessage() {} +func (*MsgRegisterTokenPriceQuery) Descriptor() ([]byte, []int) { return fileDescriptor_be640eb75c1babd5, []int{0} } -func (m *MsgAddTokenPrice) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterTokenPriceQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterTokenPriceQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddTokenPrice.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterTokenPriceQuery.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -66,75 +67,75 @@ func (m *MsgAddTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgAddTokenPrice) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddTokenPrice.Merge(m, src) +func (m *MsgRegisterTokenPriceQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterTokenPriceQuery.Merge(m, src) } -func (m *MsgAddTokenPrice) XXX_Size() int { +func (m *MsgRegisterTokenPriceQuery) XXX_Size() int { return m.Size() } -func (m *MsgAddTokenPrice) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddTokenPrice.DiscardUnknown(m) +func (m *MsgRegisterTokenPriceQuery) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterTokenPriceQuery.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddTokenPrice proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterTokenPriceQuery proto.InternalMessageInfo -func (m *MsgAddTokenPrice) GetSender() string { +func (m *MsgRegisterTokenPriceQuery) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgAddTokenPrice) GetBaseDenom() string { +func (m *MsgRegisterTokenPriceQuery) GetBaseDenom() string { if m != nil { return m.BaseDenom } return "" } -func (m *MsgAddTokenPrice) GetQuoteDenom() string { +func (m *MsgRegisterTokenPriceQuery) GetQuoteDenom() string { if m != nil { return m.QuoteDenom } return "" } -func (m *MsgAddTokenPrice) GetOsmosisBaseDenom() string { +func (m *MsgRegisterTokenPriceQuery) GetOsmosisBaseDenom() string { if m != nil { return m.OsmosisBaseDenom } return "" } -func (m *MsgAddTokenPrice) GetOsmosisQuoteDenom() string { +func (m *MsgRegisterTokenPriceQuery) GetOsmosisQuoteDenom() string { if m != nil { return m.OsmosisQuoteDenom } return "" } -func (m *MsgAddTokenPrice) GetOsmosisPoolId() string { +func (m *MsgRegisterTokenPriceQuery) GetOsmosisPoolId() string { if m != nil { return m.OsmosisPoolId } return "" } -type MsgAddTokenPriceResponse struct { +type MsgRegisterTokenPriceQueryResponse struct { } -func (m *MsgAddTokenPriceResponse) Reset() { *m = MsgAddTokenPriceResponse{} } -func (m *MsgAddTokenPriceResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddTokenPriceResponse) ProtoMessage() {} -func (*MsgAddTokenPriceResponse) Descriptor() ([]byte, []int) { +func (m *MsgRegisterTokenPriceQueryResponse) Reset() { *m = MsgRegisterTokenPriceQueryResponse{} } +func (m *MsgRegisterTokenPriceQueryResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterTokenPriceQueryResponse) ProtoMessage() {} +func (*MsgRegisterTokenPriceQueryResponse) Descriptor() ([]byte, []int) { return fileDescriptor_be640eb75c1babd5, []int{1} } -func (m *MsgAddTokenPriceResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterTokenPriceQueryResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterTokenPriceQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddTokenPriceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterTokenPriceQueryResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -144,17 +145,17 @@ func (m *MsgAddTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgAddTokenPriceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddTokenPriceResponse.Merge(m, src) +func (m *MsgRegisterTokenPriceQueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterTokenPriceQueryResponse.Merge(m, src) } -func (m *MsgAddTokenPriceResponse) XXX_Size() int { +func (m *MsgRegisterTokenPriceQueryResponse) XXX_Size() int { return m.Size() } -func (m *MsgAddTokenPriceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddTokenPriceResponse.DiscardUnknown(m) +func (m *MsgRegisterTokenPriceQueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterTokenPriceQueryResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddTokenPriceResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterTokenPriceQueryResponse proto.InternalMessageInfo // MsgRemoveTokenPrice defines the message for removing a token from price // tracking @@ -266,8 +267,8 @@ func (m *MsgRemoveTokenPriceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveTokenPriceResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgAddTokenPrice)(nil), "stride.icqoracle.MsgAddTokenPrice") - proto.RegisterType((*MsgAddTokenPriceResponse)(nil), "stride.icqoracle.MsgAddTokenPriceResponse") + proto.RegisterType((*MsgRegisterTokenPriceQuery)(nil), "stride.icqoracle.MsgRegisterTokenPriceQuery") + proto.RegisterType((*MsgRegisterTokenPriceQueryResponse)(nil), "stride.icqoracle.MsgRegisterTokenPriceQueryResponse") proto.RegisterType((*MsgRemoveTokenPrice)(nil), "stride.icqoracle.MsgRemoveTokenPrice") proto.RegisterType((*MsgRemoveTokenPriceResponse)(nil), "stride.icqoracle.MsgRemoveTokenPriceResponse") } @@ -275,36 +276,37 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 459 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x93, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0x73, 0xfd, 0x13, 0xa9, 0x2f, 0xaa, 0x48, 0x5d, 0x24, 0x5c, 0xa3, 0x1a, 0x64, 0x44, - 0x85, 0x22, 0xe2, 0x83, 0x06, 0x31, 0xb0, 0x35, 0x62, 0x41, 0x22, 0x52, 0x49, 0x99, 0x58, 0xac, - 0xc4, 0x77, 0x72, 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47, 0x2a, 0x3b, - 0x3d, 0x1f, 0xf8, 0x21, 0xc6, 0xfc, 0x44, 0x27, 0xb7, 0x5e, 0xf5, 0x07, 0xc4, 0x4d, 0xa3, 0xe3, - 0xc3, 0xa7, 0x2b, 0xad, 0x66, 0xef, 0x47, 0x92, 0x06, 0x75, 0xfd, 0x59, 0xb6, 0x7f, 0x07, 0x00, - 0x00, 0xff, 0xff, 0xdc, 0x6d, 0x69, 0x4f, 0x0c, 0x04, 0x00, 0x00, + // 472 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x93, 0x3f, 0x6f, 0xd3, 0x50, + 0x14, 0xc5, 0xe3, 0xfe, 0x89, 0xd4, 0x8b, 0x10, 0xa9, 0x8b, 0xd4, 0xd4, 0xa8, 0x06, 0x59, 0x50, + 0xa1, 0xa8, 0xb1, 0xa1, 0xad, 0x18, 0x90, 0x18, 0x88, 0x58, 0x90, 0x88, 0xd4, 0xa6, 0x4c, 0x2c, + 0x51, 0x62, 0x5f, 0xb9, 0x4f, 0xc4, 0xbe, 0xe9, 0xbb, 0x4e, 0xd4, 0x0e, 0x48, 0x88, 0x91, 0x89, + 0x8f, 0x92, 0x81, 0x0f, 0xc1, 0x58, 0xc1, 0xc2, 0x88, 0x92, 0x21, 0x9f, 0x80, 0x1d, 0xf9, 0xf9, + 0xb9, 0x4d, 0x4a, 0x2c, 0xc1, 0xd4, 0xc5, 0xd6, 0x3b, 0xe7, 0xe7, 0x63, 0xbf, 0x73, 0xfd, 0x60, + 0x8b, 0x13, 0x29, 0x02, 0xf4, 0x84, 0x7f, 0x4a, 0xb2, 0xe3, 0xf7, 0xd0, 0x4b, 0xce, 0xdc, 0xbe, + 0xa4, 0x84, 0xcc, 0x4a, 0x66, 0xb9, 0x97, 0x96, 0xb5, 0xe9, 0x13, 0x47, 0xc4, 0x5e, 0xc4, 0xa1, + 0x37, 0x7c, 0x9a, 0xde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, 0xdc, 0xa7, 0x98, 0xd1, 0x99, 0x1a, + 0xb0, 0xa1, 0xb0, 0x88, 0x86, 0x78, 0x05, 0xdd, 0x40, 0xe9, 0x0b, 0x6a, 0x59, 0x59, 0x54, 0xcb, + 0xb3, 0x6b, 0xb5, 0xec, 0x14, 0xd5, 0x32, 0xbf, 0x23, 0x67, 0x1b, 0xee, 0x2d, 0x90, 0xf3, 0x22, + 0xf6, 0x7e, 0x1b, 0xb0, 0xdc, 0xe4, 0xd0, 0xfc, 0x00, 0x9b, 0x45, 0x3f, 0xe2, 0xae, 0x7b, 0xfd, + 0x04, 0xb8, 0xc5, 0x0d, 0x5b, 0x07, 0xff, 0x43, 0xe7, 0x9f, 0x61, 0x9e, 0x40, 0xe5, 0xaf, 0x59, + 0x3c, 0x2a, 0x48, 0x9a, 0xc7, 0xac, 0xfa, 0x3f, 0x61, 0xf9, 0x9b, 0xac, 0xd5, 0x8f, 0xd3, 0x51, + 0xcd, 0x68, 0x34, 0xbf, 0x8d, 0x6d, 0xe3, 0x62, 0x6c, 0x1b, 0xbf, 0xc6, 0xb6, 0xf1, 0x65, 0x62, + 0x97, 0x2e, 0x26, 0x76, 0xe9, 0xe7, 0xc4, 0x2e, 0xbd, 0xdb, 0x0f, 0x45, 0x72, 0x32, 0xe8, 0xba, + 0x3e, 0x45, 0xde, 0xb1, 0x4a, 0xae, 0xbf, 0xe9, 0x74, 0xd9, 0xd3, 0x7d, 0x0f, 0xf7, 0x0e, 0xe6, + 0x3a, 0x4f, 0xce, 0xfb, 0xc8, 0xdd, 0xb2, 0x3a, 0xd2, 0xfb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x6e, 0x24, 0xd7, 0x3a, 0x48, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -319,8 +321,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // AddTokenPrice adds a new token to track prices for - AddTokenPrice(ctx context.Context, in *MsgAddTokenPrice, opts ...grpc.CallOption) (*MsgAddTokenPriceResponse, error) + // RegisterTokenPriceQuery registers a new token to track prices for + RegisterTokenPriceQuery(ctx context.Context, in *MsgRegisterTokenPriceQuery, opts ...grpc.CallOption) (*MsgRegisterTokenPriceQueryResponse, error) // RemoveTokenPrice removes a token from price tracking RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPrice, opts ...grpc.CallOption) (*MsgRemoveTokenPriceResponse, error) } @@ -333,9 +335,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) AddTokenPrice(ctx context.Context, in *MsgAddTokenPrice, opts ...grpc.CallOption) (*MsgAddTokenPriceResponse, error) { - out := new(MsgAddTokenPriceResponse) - err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/AddTokenPrice", in, out, opts...) +func (c *msgClient) RegisterTokenPriceQuery(ctx context.Context, in *MsgRegisterTokenPriceQuery, opts ...grpc.CallOption) (*MsgRegisterTokenPriceQueryResponse, error) { + out := new(MsgRegisterTokenPriceQueryResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/RegisterTokenPriceQuery", in, out, opts...) if err != nil { return nil, err } @@ -353,8 +355,8 @@ func (c *msgClient) RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPric // MsgServer is the server API for Msg service. type MsgServer interface { - // AddTokenPrice adds a new token to track prices for - AddTokenPrice(context.Context, *MsgAddTokenPrice) (*MsgAddTokenPriceResponse, error) + // RegisterTokenPriceQuery registers a new token to track prices for + RegisterTokenPriceQuery(context.Context, *MsgRegisterTokenPriceQuery) (*MsgRegisterTokenPriceQueryResponse, error) // RemoveTokenPrice removes a token from price tracking RemoveTokenPrice(context.Context, *MsgRemoveTokenPrice) (*MsgRemoveTokenPriceResponse, error) } @@ -363,8 +365,8 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) AddTokenPrice(ctx context.Context, req *MsgAddTokenPrice) (*MsgAddTokenPriceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddTokenPrice not implemented") +func (*UnimplementedMsgServer) RegisterTokenPriceQuery(ctx context.Context, req *MsgRegisterTokenPriceQuery) (*MsgRegisterTokenPriceQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterTokenPriceQuery not implemented") } func (*UnimplementedMsgServer) RemoveTokenPrice(ctx context.Context, req *MsgRemoveTokenPrice) (*MsgRemoveTokenPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveTokenPrice not implemented") @@ -374,20 +376,20 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_AddTokenPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddTokenPrice) +func _Msg_RegisterTokenPriceQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterTokenPriceQuery) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).AddTokenPrice(ctx, in) + return srv.(MsgServer).RegisterTokenPriceQuery(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/stride.icqoracle.Msg/AddTokenPrice", + FullMethod: "/stride.icqoracle.Msg/RegisterTokenPriceQuery", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddTokenPrice(ctx, req.(*MsgAddTokenPrice)) + return srv.(MsgServer).RegisterTokenPriceQuery(ctx, req.(*MsgRegisterTokenPriceQuery)) } return interceptor(ctx, in, info, handler) } @@ -415,8 +417,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "AddTokenPrice", - Handler: _Msg_AddTokenPrice_Handler, + MethodName: "RegisterTokenPriceQuery", + Handler: _Msg_RegisterTokenPriceQuery_Handler, }, { MethodName: "RemoveTokenPrice", @@ -427,7 +429,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "stride/icqoracle/tx.proto", } -func (m *MsgAddTokenPrice) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterTokenPriceQuery) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -437,12 +439,12 @@ func (m *MsgAddTokenPrice) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddTokenPrice) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterTokenPriceQuery) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -492,7 +494,7 @@ func (m *MsgAddTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAddTokenPriceResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterTokenPriceQueryResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -502,12 +504,12 @@ func (m *MsgAddTokenPriceResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddTokenPriceResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterTokenPriceQueryResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddTokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterTokenPriceQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -600,7 +602,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgAddTokenPrice) Size() (n int) { +func (m *MsgRegisterTokenPriceQuery) Size() (n int) { if m == nil { return 0 } @@ -633,7 +635,7 @@ func (m *MsgAddTokenPrice) Size() (n int) { return n } -func (m *MsgAddTokenPriceResponse) Size() (n int) { +func (m *MsgRegisterTokenPriceQueryResponse) Size() (n int) { if m == nil { return 0 } @@ -682,7 +684,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -705,10 +707,10 @@ func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddTokenPrice: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterTokenPriceQuery: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterTokenPriceQuery: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -924,7 +926,7 @@ func (m *MsgAddTokenPrice) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddTokenPriceResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterTokenPriceQueryResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -947,10 +949,10 @@ func (m *MsgAddTokenPriceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddTokenPriceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterTokenPriceQueryResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddTokenPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterTokenPriceQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 5aa8900332c5dd38d45791e6a3ba5df6c395882f Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:44:41 +0200 Subject: [PATCH 027/115] Fix icqoracle amino names Removes 'stride/x/' prefix from amino message names to maintain consistent naming for: - MsgRegisterTokenPriceQuery - MsgRemoveTokenPrice --- proto/stride/icqoracle/tx.proto | 4 +-- x/icqoracle/types/tx.pb.go | 62 ++++++++++++++++----------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 6c838a905c..51b7440a91 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -24,7 +24,7 @@ service Msg { // track prices message MsgRegisterTokenPriceQuery { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "stride/x/icqoracle/MsgRegisterTokenPriceQuery"; + option (amino.name) = "icqoracle/MsgRegisterTokenPriceQuery"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; @@ -46,7 +46,7 @@ message MsgRegisterTokenPriceQueryResponse {} // tracking message MsgRemoveTokenPrice { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "stride/x/icqoracle/MsgRemoveTokenPrice"; + option (amino.name) = "icqoracle/MsgRemoveTokenPrice"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index 96ee5cec73..2a660eeb94 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -276,37 +276,37 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 472 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x93, 0x3f, 0x6f, 0xd3, 0x50, - 0x14, 0xc5, 0xe3, 0xfe, 0x89, 0xd4, 0x8b, 0x10, 0xa9, 0x8b, 0xd4, 0xd4, 0xa8, 0x06, 0x59, 0x50, - 0xa1, 0xa8, 0xb1, 0xa1, 0xad, 0x18, 0x90, 0x18, 0x88, 0x58, 0x90, 0x88, 0xd4, 0xa6, 0x4c, 0x2c, - 0x51, 0x62, 0x5f, 0xb9, 0x4f, 0xc4, 0xbe, 0xe9, 0xbb, 0x4e, 0xd4, 0x0e, 0x48, 0x88, 0x91, 0x89, - 0x8f, 0x92, 0x81, 0x0f, 0xc1, 0x58, 0xc1, 0xc2, 0x88, 0x92, 0x21, 0x9f, 0x80, 0x1d, 0xf9, 0xf9, - 0xb9, 0x4d, 0x4a, 0x2c, 0xc1, 0xd4, 0xc5, 0xd6, 0x3b, 0xe7, 0xe7, 0x63, 0xbf, 0x73, 0xfd, 0x60, - 0x8b, 0x13, 0x29, 0x02, 0xf4, 0x84, 0x7f, 0x4a, 0xb2, 0xe3, 0xf7, 0xd0, 0x4b, 0xce, 0xdc, 0xbe, - 0xa4, 0x84, 0xcc, 0x4a, 0x66, 0xb9, 0x97, 0x96, 0xb5, 0xe9, 0x13, 0x47, 0xc4, 0x5e, 0xc4, 0xa1, - 0x37, 0x7c, 0x9a, 0xde, 0x32, 0xd4, 0x5a, 0xef, 0x44, 0x22, 0x26, 0x4f, 0x5d, 0xb5, 0xb4, 0x95, - 0xb1, 0x6d, 0xb5, 0xf2, 0xb2, 0x45, 0x66, 0x39, 0x3f, 0x96, 0xc0, 0x6a, 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 0xb5, 0xec, 0x14, 0xd5, 0x32, 0xbf, 0x23, 0x67, 0x1b, 0xee, 0x2d, 0x90, 0xf3, 0x22, - 0xf6, 0x7e, 0x1b, 0xb0, 0xdc, 0xe4, 0xd0, 0xfc, 0x00, 0x9b, 0x45, 0x3f, 0xe2, 0xae, 0x7b, 0xfd, - 0x04, 0xb8, 0xc5, 0x0d, 0x5b, 0x07, 0xff, 0x43, 0xe7, 0x9f, 0x61, 0x9e, 0x40, 0xe5, 0xaf, 0x59, - 0x3c, 0x2a, 0x48, 0x9a, 0xc7, 0xac, 0xfa, 0x3f, 0x61, 0xf9, 0x9b, 0xac, 0xd5, 0x8f, 0xd3, 0x51, - 0xcd, 0x68, 0x34, 0xbf, 0x8d, 0x6d, 0xe3, 0x62, 0x6c, 0x1b, 0xbf, 0xc6, 0xb6, 0xf1, 0x65, 0x62, - 0x97, 0x2e, 0x26, 0x76, 0xe9, 0xe7, 0xc4, 0x2e, 0xbd, 0xdb, 0x0f, 0x45, 0x72, 0x32, 0xe8, 0xba, - 0x3e, 0x45, 0xde, 0xb1, 0x4a, 0xae, 0xbf, 0xe9, 0x74, 0xd9, 0xd3, 0x7d, 0x0f, 0xf7, 0x0e, 0xe6, - 0x3a, 0x4f, 0xce, 0xfb, 0xc8, 0xdd, 0xb2, 0x3a, 0xd2, 0xfb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x6e, 0x24, 0xd7, 0x3a, 0x48, 0x04, 0x00, 0x00, + // 470 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0xe3, 0xfe, 0x89, 0xd4, 0x17, 0x21, 0x52, 0x17, 0xa9, 0xa9, 0x51, 0x0c, 0xb2, 0x0a, + 0x42, 0x51, 0xe3, 0x83, 0x36, 0x13, 0x1b, 0x11, 0x0b, 0x12, 0x91, 0xda, 0x94, 0x89, 0x25, 0x4a, + 0xec, 0x57, 0xee, 0x89, 0xd8, 0x6f, 0x7a, 0xaf, 0x13, 0xb5, 0x03, 0x12, 0x62, 0x64, 0xe2, 0xa3, + 0x64, 0xe0, 0x43, 0x20, 0xa6, 0x8a, 0x89, 0x09, 0xa1, 0x64, 0xc8, 0x27, 0x60, 0x47, 0x39, 0xdb, + 0x4d, 0x1a, 0x62, 0x09, 0x26, 0x16, 0x5b, 0xf7, 0x3c, 0x3f, 0x3f, 0xf6, 0x3d, 0x77, 0x3e, 0xd8, + 0xe3, 0x58, 0x49, 0x1f, 0x85, 0xf4, 0xce, 0x49, 0x75, 0xbc, 0x1e, 0x8a, 0xf8, 0xc2, 0xed, 0x2b, + 0x8a, 0xc9, 0x2c, 0x25, 0x96, 0x7b, 0x6d, 0x59, 0xbb, 0x1e, 0x71, 0x48, 0x2c, 0x42, 0x0e, 0xc4, + 0xf0, 0xe9, 0xec, 0x96, 0xa0, 0xd6, 0x76, 0x27, 0x94, 0x11, 0x09, 0x7d, 0x4d, 0xa5, 0xbd, 0x84, + 0x6d, 0xeb, 0x91, 0x48, 0x06, 0x89, 0xe5, 0x7c, 0x5d, 0x03, 0xab, 0xc9, 0x41, 0x0b, 0x03, 0xc9, + 0x31, 0xaa, 0xd7, 0xf4, 0x16, 0xa3, 0x63, 0x25, 0x3d, 0x3c, 0x19, 0xa0, 0xba, 0x34, 0x9f, 0x40, + 0x91, 0x31, 0xf2, 0x51, 0x95, 0x8d, 0x07, 0xc6, 0xe3, 0xad, 0x46, 0xf9, 0xdb, 0xe7, 0xda, 0xdd, + 0x34, 0xe0, 0xb9, 0xef, 0x2b, 0x64, 0x3e, 0x8d, 0x95, 0x8c, 0x82, 0x56, 0xca, 0x99, 0x15, 0x80, + 0x6e, 0x87, 0xb1, 0xed, 0x63, 0x44, 0x61, 0x79, 0x6d, 0xf6, 0x54, 0x6b, 0x6b, 0xa6, 0xbc, 0x98, + 0x09, 0xe6, 0x7d, 0x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, 0x6d, 0x7c, 0x9a, 0xd8, 0x85, 0xab, 0x89, + 0x5d, 0xf8, 0x3e, 0xb1, 0x0b, 0x6f, 0x8e, 0x02, 0x19, 0x9f, 0x0d, 0xba, 0xae, 0x47, 0xa1, 0x38, + 0xd5, 0xc9, 0xb5, 0x57, 0x9d, 0x2e, 0x8b, 0xf4, 0x3c, 0x18, 0x1e, 0xd6, 0xc5, 0xc5, 0xe2, 0xa9, + 0x70, 0xd9, 0x47, 0xee, 0x16, 0xf5, 0x0f, 0x7c, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x7c, + 0x9f, 0x48, 0x36, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From 6913cd784d737ab9e177b8825074c55ce4428289 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:48:35 +0200 Subject: [PATCH 028/115] s/MsgRemoveTokenPrice/MsgRemoveTokenPriceQuery/g --- proto/stride/icqoracle/tx.proto | 14 +-- x/icqoracle/client/cli/tx.go | 2 +- x/icqoracle/keeper/msg_server.go | 6 +- x/icqoracle/types/codec.go | 4 +- x/icqoracle/types/msgs.go | 24 ++-- x/icqoracle/types/tx.pb.go | 192 +++++++++++++++---------------- 6 files changed, 121 insertions(+), 121 deletions(-) diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 51b7440a91..599ed122ed 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -15,9 +15,9 @@ service Msg { rpc RegisterTokenPriceQuery(MsgRegisterTokenPriceQuery) returns (MsgRegisterTokenPriceQueryResponse); - // RemoveTokenPrice removes a token from price tracking - rpc RemoveTokenPrice(MsgRemoveTokenPrice) - returns (MsgRemoveTokenPriceResponse); + // RemoveTokenPriceQuery removes a token from price tracking + rpc RemoveTokenPriceQuery(MsgRemoveTokenPriceQuery) + returns (MsgRemoveTokenPriceQueryResponse); } // MsgRegisterTokenPriceQuery defines the message for adding a new token to @@ -42,11 +42,11 @@ message MsgRegisterTokenPriceQuery { message MsgRegisterTokenPriceQueryResponse {} -// MsgRemoveTokenPrice defines the message for removing a token from price +// MsgRemoveTokenPriceQuery defines the message for removing a token from price // tracking -message MsgRemoveTokenPrice { +message MsgRemoveTokenPriceQuery { option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "icqoracle/MsgRemoveTokenPrice"; + option (amino.name) = "icqoracle/MsgRemoveTokenPriceQuery"; string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") @@ -57,4 +57,4 @@ message MsgRemoveTokenPrice { string osmosis_pool_id = 4; } -message MsgRemoveTokenPriceResponse {} \ No newline at end of file +message MsgRemoveTokenPriceQueryResponse {} \ No newline at end of file diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go index 48fb9a0196..5b01a1cefc 100644 --- a/x/icqoracle/client/cli/tx.go +++ b/x/icqoracle/client/cli/tx.go @@ -89,7 +89,7 @@ Example: return err } - msg := types.NewMsgRemoveTokenPrice( + msg := types.NewMsgRemoveTokenPriceQuery( clientCtx.GetFromAddress().String(), args[0], args[1], diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index b5045cd17c..bbb0d60260 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -47,8 +47,8 @@ func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.Ms return &types.MsgRegisterTokenPriceQueryResponse{}, nil } -// RemoveTokenPrice removes a token from price tracking -func (ms msgServer) RemoveTokenPrice(goCtx context.Context, msg *types.MsgRemoveTokenPrice) (*types.MsgRemoveTokenPriceResponse, error) { +// RemoveTokenPriceQuery removes a token from price tracking +func (ms msgServer) RemoveTokenPriceQuery(goCtx context.Context, msg *types.MsgRemoveTokenPriceQuery) (*types.MsgRemoveTokenPriceQueryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // TODO check admin @@ -60,5 +60,5 @@ func (ms msgServer) RemoveTokenPrice(goCtx context.Context, msg *types.MsgRemove } ms.Keeper.RemoveTokenPrice(ctx, tokenPrice) - return &types.MsgRemoveTokenPriceResponse{}, nil + return &types.MsgRemoveTokenPriceQueryResponse{}, nil } diff --git a/x/icqoracle/types/codec.go b/x/icqoracle/types/codec.go index ebc9a0dc0a..1c2bbd1582 100644 --- a/x/icqoracle/types/codec.go +++ b/x/icqoracle/types/codec.go @@ -12,13 +12,13 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgRegisterTokenPriceQuery{}, "icqoracle/MsgRegisterTokenPriceQuery") - legacy.RegisterAminoMsg(cdc, &MsgRemoveTokenPrice{}, "icqoracle/MsgRemoveTokenPrice") + legacy.RegisterAminoMsg(cdc, &MsgRemoveTokenPriceQuery{}, "icqoracle/MsgRemoveTokenPriceQuery") } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterTokenPriceQuery{}, - &MsgRemoveTokenPrice{}, + &MsgRemoveTokenPriceQuery{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 176bfe636d..4676c5d0bd 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -12,16 +12,16 @@ import ( const ( TypeMsgRegisterTokenPriceQuery = "register_token_price_query" - TypeMsgRemoveTokenPrice = "remove_token_price" + TypeMsgRemoveTokenPriceQuery = "remove_token_price_query" ) var ( _ sdk.Msg = &MsgRegisterTokenPriceQuery{} - _ sdk.Msg = &MsgRemoveTokenPrice{} + _ sdk.Msg = &MsgRemoveTokenPriceQuery{} // Implement legacy interface for ledger support _ legacytx.LegacyMsg = &MsgRegisterTokenPriceQuery{} - _ legacytx.LegacyMsg = &MsgRemoveTokenPrice{} + _ legacytx.LegacyMsg = &MsgRemoveTokenPriceQuery{} ) // ---------------------------------------------- @@ -84,11 +84,11 @@ func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { } // ---------------------------------------------- -// MsgRemoveTokenPrice +// MsgRemoveTokenPriceQuery // ---------------------------------------------- -func NewMsgRemoveTokenPrice(sender, baseDenom, quoteDenom, osmosisPoolId string) *MsgRemoveTokenPrice { - return &MsgRemoveTokenPrice{ +func NewMsgRemoveTokenPriceQuery(sender, baseDenom, quoteDenom, osmosisPoolId string) *MsgRemoveTokenPriceQuery { + return &MsgRemoveTokenPriceQuery{ Sender: sender, BaseDenom: baseDenom, QuoteDenom: quoteDenom, @@ -96,15 +96,15 @@ func NewMsgRemoveTokenPrice(sender, baseDenom, quoteDenom, osmosisPoolId string) } } -func (msg MsgRemoveTokenPrice) Type() string { - return TypeMsgRemoveTokenPrice +func (msg MsgRemoveTokenPriceQuery) Type() string { + return TypeMsgRemoveTokenPriceQuery } -func (msg MsgRemoveTokenPrice) Route() string { +func (msg MsgRemoveTokenPriceQuery) Route() string { return RouterKey } -func (msg *MsgRemoveTokenPrice) GetSigners() []sdk.AccAddress { +func (msg *MsgRemoveTokenPriceQuery) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { panic(err) @@ -112,12 +112,12 @@ func (msg *MsgRemoveTokenPrice) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } -func (msg *MsgRemoveTokenPrice) GetSignBytes() []byte { +func (msg *MsgRemoveTokenPriceQuery) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgRemoveTokenPrice) ValidateBasic() error { +func (msg *MsgRemoveTokenPriceQuery) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index 2a660eeb94..3819b33ac4 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -157,9 +157,9 @@ func (m *MsgRegisterTokenPriceQueryResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterTokenPriceQueryResponse proto.InternalMessageInfo -// MsgRemoveTokenPrice defines the message for removing a token from price +// MsgRemoveTokenPriceQuery defines the message for removing a token from price // tracking -type MsgRemoveTokenPrice struct { +type MsgRemoveTokenPriceQuery struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // Token denom on its base chain (e.g. "uosmo", "uatom", "udym") BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` @@ -169,18 +169,18 @@ type MsgRemoveTokenPrice struct { OsmosisPoolId string `protobuf:"bytes,4,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } -func (m *MsgRemoveTokenPrice) Reset() { *m = MsgRemoveTokenPrice{} } -func (m *MsgRemoveTokenPrice) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveTokenPrice) ProtoMessage() {} -func (*MsgRemoveTokenPrice) Descriptor() ([]byte, []int) { +func (m *MsgRemoveTokenPriceQuery) Reset() { *m = MsgRemoveTokenPriceQuery{} } +func (m *MsgRemoveTokenPriceQuery) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveTokenPriceQuery) ProtoMessage() {} +func (*MsgRemoveTokenPriceQuery) Descriptor() ([]byte, []int) { return fileDescriptor_be640eb75c1babd5, []int{2} } -func (m *MsgRemoveTokenPrice) XXX_Unmarshal(b []byte) error { +func (m *MsgRemoveTokenPriceQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRemoveTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRemoveTokenPriceQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRemoveTokenPrice.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRemoveTokenPriceQuery.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -190,61 +190,61 @@ func (m *MsgRemoveTokenPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgRemoveTokenPrice) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveTokenPrice.Merge(m, src) +func (m *MsgRemoveTokenPriceQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveTokenPriceQuery.Merge(m, src) } -func (m *MsgRemoveTokenPrice) XXX_Size() int { +func (m *MsgRemoveTokenPriceQuery) XXX_Size() int { return m.Size() } -func (m *MsgRemoveTokenPrice) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveTokenPrice.DiscardUnknown(m) +func (m *MsgRemoveTokenPriceQuery) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveTokenPriceQuery.DiscardUnknown(m) } -var xxx_messageInfo_MsgRemoveTokenPrice proto.InternalMessageInfo +var xxx_messageInfo_MsgRemoveTokenPriceQuery proto.InternalMessageInfo -func (m *MsgRemoveTokenPrice) GetSender() string { +func (m *MsgRemoveTokenPriceQuery) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgRemoveTokenPrice) GetBaseDenom() string { +func (m *MsgRemoveTokenPriceQuery) GetBaseDenom() string { if m != nil { return m.BaseDenom } return "" } -func (m *MsgRemoveTokenPrice) GetQuoteDenom() string { +func (m *MsgRemoveTokenPriceQuery) GetQuoteDenom() string { if m != nil { return m.QuoteDenom } return "" } -func (m *MsgRemoveTokenPrice) GetOsmosisPoolId() string { +func (m *MsgRemoveTokenPriceQuery) GetOsmosisPoolId() string { if m != nil { return m.OsmosisPoolId } return "" } -type MsgRemoveTokenPriceResponse struct { +type MsgRemoveTokenPriceQueryResponse struct { } -func (m *MsgRemoveTokenPriceResponse) Reset() { *m = MsgRemoveTokenPriceResponse{} } -func (m *MsgRemoveTokenPriceResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveTokenPriceResponse) ProtoMessage() {} -func (*MsgRemoveTokenPriceResponse) Descriptor() ([]byte, []int) { +func (m *MsgRemoveTokenPriceQueryResponse) Reset() { *m = MsgRemoveTokenPriceQueryResponse{} } +func (m *MsgRemoveTokenPriceQueryResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveTokenPriceQueryResponse) ProtoMessage() {} +func (*MsgRemoveTokenPriceQueryResponse) Descriptor() ([]byte, []int) { return fileDescriptor_be640eb75c1babd5, []int{3} } -func (m *MsgRemoveTokenPriceResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgRemoveTokenPriceQueryResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRemoveTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRemoveTokenPriceQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRemoveTokenPriceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRemoveTokenPriceQueryResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -254,59 +254,59 @@ func (m *MsgRemoveTokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgRemoveTokenPriceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveTokenPriceResponse.Merge(m, src) +func (m *MsgRemoveTokenPriceQueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveTokenPriceQueryResponse.Merge(m, src) } -func (m *MsgRemoveTokenPriceResponse) XXX_Size() int { +func (m *MsgRemoveTokenPriceQueryResponse) XXX_Size() int { return m.Size() } -func (m *MsgRemoveTokenPriceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveTokenPriceResponse.DiscardUnknown(m) +func (m *MsgRemoveTokenPriceQueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveTokenPriceQueryResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgRemoveTokenPriceResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgRemoveTokenPriceQueryResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgRegisterTokenPriceQuery)(nil), "stride.icqoracle.MsgRegisterTokenPriceQuery") proto.RegisterType((*MsgRegisterTokenPriceQueryResponse)(nil), "stride.icqoracle.MsgRegisterTokenPriceQueryResponse") - proto.RegisterType((*MsgRemoveTokenPrice)(nil), "stride.icqoracle.MsgRemoveTokenPrice") - proto.RegisterType((*MsgRemoveTokenPriceResponse)(nil), "stride.icqoracle.MsgRemoveTokenPriceResponse") + proto.RegisterType((*MsgRemoveTokenPriceQuery)(nil), "stride.icqoracle.MsgRemoveTokenPriceQuery") + proto.RegisterType((*MsgRemoveTokenPriceQueryResponse)(nil), "stride.icqoracle.MsgRemoveTokenPriceQueryResponse") } func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 470 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0xe3, 0xfe, 0x89, 0xd4, 0x17, 0x21, 0x52, 0x17, 0xa9, 0xa9, 0x51, 0x0c, 0xb2, 0x0a, - 0x42, 0x51, 0xe3, 0x83, 0x36, 0x13, 0x1b, 0x11, 0x0b, 0x12, 0x91, 0xda, 0x94, 0x89, 0x25, 0x4a, - 0xec, 0x57, 0xee, 0x89, 0xd8, 0x6f, 0x7a, 0xaf, 0x13, 0xb5, 0x03, 0x12, 0x62, 0x64, 0xe2, 0xa3, - 0x64, 0xe0, 0x43, 0x20, 0xa6, 0x8a, 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xb5, 0x57, 0x9d, 0x2e, 0x8b, 0xf4, 0x3c, 0x18, 0x1e, 0xd6, 0xc5, 0xc5, 0xe2, 0xa9, - 0x70, 0xd9, 0x47, 0xee, 0x16, 0xf5, 0x0f, 0x7c, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x7c, - 0x9f, 0x48, 0x36, 0x04, 0x00, 0x00, + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0xb1, 0x6f, 0xd3, 0x40, + 0x14, 0xc6, 0xe3, 0xb4, 0x8d, 0xd4, 0x87, 0x10, 0xad, 0x01, 0xd5, 0xb5, 0x84, 0xa9, 0xac, 0x0a, + 0xa1, 0xa8, 0xf5, 0x41, 0x9a, 0x89, 0x8d, 0x88, 0x05, 0x89, 0x48, 0x6d, 0xca, 0xc4, 0x12, 0x25, + 0xf6, 0x93, 0x39, 0x11, 0xfb, 0xa5, 0xf7, 0x9c, 0xd0, 0x0e, 0x48, 0x08, 0x31, 0x31, 0xf1, 0xa7, + 0x64, 0xe0, 0x8f, 0x40, 0x4c, 0x15, 0x13, 0x23, 0x4a, 0x86, 0xf0, 0x67, 0xa0, 0x9c, 0xed, 0x36, + 0x8a, 0x6c, 0x09, 0xa6, 0x2e, 0xb6, 0xee, 0xfb, 0x7e, 0xfe, 0xec, 0xfb, 0xee, 0x7c, 0xb0, 0xcb, + 0x89, 0x92, 0x01, 0x0a, 0xe9, 0x9f, 0x91, 0xea, 0xf9, 0x03, 0x14, 0xc9, 0xb9, 0x37, 0x54, 0x94, + 0x90, 0xb9, 0x95, 0x5a, 0xde, 0x95, 0x65, 0xef, 0xf8, 0xc4, 0x11, 0xb1, 0x88, 0x38, 0x14, 0xe3, + 0xa7, 0x8b, 0x5b, 0x8a, 0xda, 0xdb, 0xbd, 0x48, 0xc6, 0x24, 0xf4, 0x35, 0x93, 0x76, 0x53, 0xb6,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 0x5e, 0x50, 0xc9, 0x7a, 0x51, 0x25, 0x8d, 0x95, 0x4a, 0xdc, 0x95, 0x4a, + 0x0a, 0x66, 0xe3, 0xba, 0xb0, 0x57, 0xe6, 0xe5, 0x75, 0x34, 0x3e, 0x57, 0x61, 0xad, 0xcd, 0xa1, + 0xf9, 0x01, 0x76, 0xca, 0x76, 0xe1, 0x81, 0xb7, 0xba, 0xfd, 0xbd, 0xf2, 0x9e, 0xed, 0xe6, 0xff, + 0xd0, 0xf9, 0x67, 0x98, 0xef, 0xe1, 0x7e, 0xf1, 0x8a, 0xd4, 0x4b, 0xe2, 0x0a, 0x58, 0xbb, 0xf1, + 0xef, 0x6c, 0xfe, 0x62, 0x7b, 0xe3, 0xe3, 0x7c, 0x52, 0x37, 0x5a, 0xed, 0xef, 0x53, 0xc7, 0xb8, + 0x9c, 0x3a, 0xc6, 0xef, 0xa9, 0x63, 0x7c, 0x9d, 0x39, 0x95, 0xcb, 0x99, 0x53, 0xf9, 0x35, 0x73, + 0x2a, 0x6f, 0x8e, 0x42, 0x99, 0xbc, 0x1d, 0xf5, 0x3d, 0x9f, 0x22, 0x71, 0xaa, 0xe3, 0x0f, 0x5f, + 0xf5, 0xfa, 0x2c, 0xb2, 0xd3, 0x62, 0xdc, 0x68, 0x8a, 0xf3, 0xe5, 0x33, 0xe3, 0x62, 0x88, 0xdc, + 0xaf, 0xe9, 0xdf, 0xfb, 0xe8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0x60, 0x42, 0x55, 0x54, + 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -323,8 +323,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // RegisterTokenPriceQuery registers a new token to track prices for RegisterTokenPriceQuery(ctx context.Context, in *MsgRegisterTokenPriceQuery, opts ...grpc.CallOption) (*MsgRegisterTokenPriceQueryResponse, error) - // RemoveTokenPrice removes a token from price tracking - RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPrice, opts ...grpc.CallOption) (*MsgRemoveTokenPriceResponse, error) + // RemoveTokenPriceQuery removes a token from price tracking + RemoveTokenPriceQuery(ctx context.Context, in *MsgRemoveTokenPriceQuery, opts ...grpc.CallOption) (*MsgRemoveTokenPriceQueryResponse, error) } type msgClient struct { @@ -344,9 +344,9 @@ func (c *msgClient) RegisterTokenPriceQuery(ctx context.Context, in *MsgRegister return out, nil } -func (c *msgClient) RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPrice, opts ...grpc.CallOption) (*MsgRemoveTokenPriceResponse, error) { - out := new(MsgRemoveTokenPriceResponse) - err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/RemoveTokenPrice", in, out, opts...) +func (c *msgClient) RemoveTokenPriceQuery(ctx context.Context, in *MsgRemoveTokenPriceQuery, opts ...grpc.CallOption) (*MsgRemoveTokenPriceQueryResponse, error) { + out := new(MsgRemoveTokenPriceQueryResponse) + err := c.cc.Invoke(ctx, "/stride.icqoracle.Msg/RemoveTokenPriceQuery", in, out, opts...) if err != nil { return nil, err } @@ -357,8 +357,8 @@ func (c *msgClient) RemoveTokenPrice(ctx context.Context, in *MsgRemoveTokenPric type MsgServer interface { // RegisterTokenPriceQuery registers a new token to track prices for RegisterTokenPriceQuery(context.Context, *MsgRegisterTokenPriceQuery) (*MsgRegisterTokenPriceQueryResponse, error) - // RemoveTokenPrice removes a token from price tracking - RemoveTokenPrice(context.Context, *MsgRemoveTokenPrice) (*MsgRemoveTokenPriceResponse, error) + // RemoveTokenPriceQuery removes a token from price tracking + RemoveTokenPriceQuery(context.Context, *MsgRemoveTokenPriceQuery) (*MsgRemoveTokenPriceQueryResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -368,8 +368,8 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) RegisterTokenPriceQuery(ctx context.Context, req *MsgRegisterTokenPriceQuery) (*MsgRegisterTokenPriceQueryResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterTokenPriceQuery not implemented") } -func (*UnimplementedMsgServer) RemoveTokenPrice(ctx context.Context, req *MsgRemoveTokenPrice) (*MsgRemoveTokenPriceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveTokenPrice not implemented") +func (*UnimplementedMsgServer) RemoveTokenPriceQuery(ctx context.Context, req *MsgRemoveTokenPriceQuery) (*MsgRemoveTokenPriceQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveTokenPriceQuery not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -394,20 +394,20 @@ func _Msg_RegisterTokenPriceQuery_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } -func _Msg_RemoveTokenPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRemoveTokenPrice) +func _Msg_RemoveTokenPriceQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveTokenPriceQuery) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).RemoveTokenPrice(ctx, in) + return srv.(MsgServer).RemoveTokenPriceQuery(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/stride.icqoracle.Msg/RemoveTokenPrice", + FullMethod: "/stride.icqoracle.Msg/RemoveTokenPriceQuery", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RemoveTokenPrice(ctx, req.(*MsgRemoveTokenPrice)) + return srv.(MsgServer).RemoveTokenPriceQuery(ctx, req.(*MsgRemoveTokenPriceQuery)) } return interceptor(ctx, in, info, handler) } @@ -421,8 +421,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RegisterTokenPriceQuery_Handler, }, { - MethodName: "RemoveTokenPrice", - Handler: _Msg_RemoveTokenPrice_Handler, + MethodName: "RemoveTokenPriceQuery", + Handler: _Msg_RemoveTokenPriceQuery_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -517,7 +517,7 @@ func (m *MsgRegisterTokenPriceQueryResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *MsgRemoveTokenPrice) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveTokenPriceQuery) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -527,12 +527,12 @@ func (m *MsgRemoveTokenPrice) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRemoveTokenPrice) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveTokenPriceQuery) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRemoveTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -568,7 +568,7 @@ func (m *MsgRemoveTokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgRemoveTokenPriceResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveTokenPriceQueryResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -578,12 +578,12 @@ func (m *MsgRemoveTokenPriceResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgRemoveTokenPriceResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveTokenPriceQueryResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRemoveTokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveTokenPriceQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -644,7 +644,7 @@ func (m *MsgRegisterTokenPriceQueryResponse) Size() (n int) { return n } -func (m *MsgRemoveTokenPrice) Size() (n int) { +func (m *MsgRemoveTokenPriceQuery) Size() (n int) { if m == nil { return 0 } @@ -669,7 +669,7 @@ func (m *MsgRemoveTokenPrice) Size() (n int) { return n } -func (m *MsgRemoveTokenPriceResponse) Size() (n int) { +func (m *MsgRemoveTokenPriceQueryResponse) Size() (n int) { if m == nil { return 0 } @@ -976,7 +976,7 @@ func (m *MsgRegisterTokenPriceQueryResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRemoveTokenPrice) Unmarshal(dAtA []byte) error { +func (m *MsgRemoveTokenPriceQuery) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -999,10 +999,10 @@ func (m *MsgRemoveTokenPrice) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveTokenPrice: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRemoveTokenPriceQuery: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveTokenPrice: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRemoveTokenPriceQuery: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1154,7 +1154,7 @@ func (m *MsgRemoveTokenPrice) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRemoveTokenPriceResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRemoveTokenPriceQueryResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1177,10 +1177,10 @@ func (m *MsgRemoveTokenPriceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveTokenPriceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRemoveTokenPriceQueryResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveTokenPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRemoveTokenPriceQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From ce9021d6ecccdc6ccca1583e66994599155bb309 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:49:44 +0200 Subject: [PATCH 029/115] fix required args for remove-token-price cli --- x/icqoracle/client/cli/tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go index 5b01a1cefc..7a00cdda75 100644 --- a/x/icqoracle/client/cli/tx.go +++ b/x/icqoracle/client/cli/tx.go @@ -82,7 +82,7 @@ Example: $ %[1]s tx %[2]s remove-token-price uatom uosmo 123 --from admin `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { From e48baae7ccbc77e6aa15df75c863a68324761a29 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 12:55:28 +0200 Subject: [PATCH 030/115] add error logging for osmosis cl pool icq submission failure --- x/icqoracle/keeper/abci.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index e4f025d9a5..05639548e4 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -23,7 +23,14 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { // Update price for this specific token err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice) if err != nil { - // TODO handle error, maybe log it + // Can't really do anything but log + ctx.Logger().Error( + "failed to submit Osmosis CL pool ICQ error='%w' baseToken='%s' quoteToken='%s' poolId='%s'", + err, + tokenPrice.BaseDenom, + tokenPrice.QuoteDenom, + tokenPrice.OsmosisPoolId, + ) continue } } From a0face12389fecb701676d9a64b599065e147dbe Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 13:02:23 +0200 Subject: [PATCH 031/115] simplify icq data passing --- x/icqoracle/keeper/icq.go | 49 +++++---------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index f65ad9c3c2..ed7ec20a4a 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -3,7 +3,6 @@ package keeper import ( "encoding/hex" "fmt" - "regexp" "strconv" "time" @@ -84,7 +83,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( QueryType: icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, RequestData: icqtypes.FormatOsmosisKeyPool(osmosisPoolId), CallbackModule: types.ModuleName, - CallbackId: queryId, + CallbackId: ICQCallbackID_OsmosisClPool, CallbackData: tokenPriceBz, TimeoutDuration: time.Duration(params.IcqTimeoutSec) * time.Second, TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, @@ -102,46 +101,18 @@ func (k Keeper) SubmitOsmosisClPoolICQ( return nil } -var queryIdRegex = regexp.MustCompile(`^(.+)\|(.+)\|(\d+)\|(\d+)$`) - -// Helper function to parse the ID string -func parseQueryID(id string) (baseDenom, quoteDenom, poolId, blockHeight string, ok bool) { - matches := queryIdRegex.FindStringSubmatch(id) - if len(matches) != 5 { - return "", "", "", "", false - } - return matches[1], matches[2], matches[3], matches[4], true -} - func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { - // TODO is this check even needed? - if query.Id != query.CallbackId { - return fmt.Errorf("query.Id ('%s') != query.CallbackId ('%s')", query.Id, query.CallbackId) - } - - baseDenom, quoteDenom, poolId, _, ok := parseQueryID(query.Id) - if !ok { - return fmt.Errorf("Error parsing baseDenom and quoteDenom from queryId '%s'", query.Id) - } - var tokenPrice types.TokenPrice if err := k.cdc.Unmarshal(query.CallbackData, &tokenPrice); err != nil { return fmt.Errorf("Error deserializing query.CallbackData '%s' as TokenPrice", hex.EncodeToString(query.CallbackData)) } - // TODO is this check even needed? - if tokenPrice.BaseDenom != baseDenom { - return fmt.Errorf("tokenPrice.BaseDenom ('%s') != baseDenom ('%s')", tokenPrice.BaseDenom, baseDenom) - } - - // TODO is this check even needed? - if tokenPrice.QuoteDenom != quoteDenom { - return fmt.Errorf("tokenPrice.QuoteDenom ('%s') != quoteDenom ('%s')", tokenPrice.QuoteDenom, quoteDenom) - } + k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "OsmosisClPool", + "Starting OsmosisClPool ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) - // TODO is this check even needed? - if tokenPrice.OsmosisPoolId != poolId { - return fmt.Errorf("tokenPrice.OsmosisPoolId ('%s') != poolId ('%s')", tokenPrice.OsmosisPoolId, poolId) + tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) + if err != nil { + return errorsmod.Wrap(err, "Error getting current spot price") } // TODO review this @@ -150,14 +121,6 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype return nil } - k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "OsmosisClPool", - "Starting OsmosisClPool ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) - - tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) - if err != nil { - return errorsmod.Wrap(err, "Error getting current spot price") - } - // Unmarshal the query response args to determine the balance newSpotPrice, err := unmarshalSpotPriceFromOsmosisClPool(tokenPrice, args) if err != nil { From b70183951d96fa66a113d52c6a5524d3fad33ea1 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 13:03:31 +0200 Subject: [PATCH 032/115] remove unnecessary crap --- x/icqoracle/keeper/keeper.go | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 44df0d77f6..7a5019bb2d 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -1,9 +1,7 @@ package keeper import ( - "encoding/binary" "fmt" - "time" "github.com/cometbft/cometbft/libs/log" @@ -36,25 +34,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// SetLastUpdateTime stores the last time prices were updated -func (k Keeper) SetLastUpdateTime(ctx sdk.Context, timestamp time.Time) { - store := ctx.KVStore(k.storeKey) - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, uint64(ctx.BlockTime().UnixNano())) - store.Set([]byte(types.KeyLastUpdateTime), bz) -} - -// GetLastUpdateTime retrieves the last time prices were updated -func (k Keeper) GetLastUpdateTime(ctx sdk.Context) (time.Time, error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get([]byte(types.KeyLastUpdateTime)) - if bz == nil { - return time.Time{}, fmt.Errorf("last update time not found") - } - nanos := int64(binary.BigEndian.Uint64(bz)) - return time.Unix(0, nanos), nil -} - // SetTokenPrice stores price data for a token func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { store := ctx.KVStore(k.storeKey) From cc4b4b3625fc9db49fd2992908f8ee67eca0e4ee Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 13:05:00 +0200 Subject: [PATCH 033/115] fix module.go --- x/icqoracle/module.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/x/icqoracle/module.go b/x/icqoracle/module.go index 3a22d5ded0..d7102d32fc 100644 --- a/x/icqoracle/module.go +++ b/x/icqoracle/module.go @@ -1,6 +1,7 @@ package icqoracle import ( + "context" "encoding/json" "fmt" @@ -16,6 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/Stride-Labs/stride/v24/x/icqoracle/client/cli" "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) @@ -72,24 +74,19 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // TODO: Queries - // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - // panic(err) - // } + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. func (a AppModuleBasic) GetTxCmd() *cobra.Command { - // TODO: messages - // return cli.GetTxCmd() - return nil + return cli.GetTxCmd() } // GetQueryCmd returns the capability module's root query command. func (AppModuleBasic) GetQueryCmd() *cobra.Command { - // TODO: Queries - // return cli.GetQueryCmd() - return nil + return cli.GetQueryCmd() } // ---------------------------------------------------------------------------- @@ -121,9 +118,8 @@ func (am AppModule) Name() string { // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - // TODO: Queries and Messages - // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } // RegisterInvariants registers the capability module's invariants. From 059505e152c2392108e4695f7a72a9239c26878f Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 13:06:41 +0200 Subject: [PATCH 034/115] update token price key format to use separator --- x/icqoracle/types/keys.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 45d60f2431..691934fcb9 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -17,5 +17,5 @@ const ( ) func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { - return []byte(fmt.Sprintf("%s%s%s%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) + return []byte(fmt.Sprintf("%s|%s|%s|%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) } From c0c1eb9155990ef2e877bf73f562b6081c884c74 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 13:13:12 +0200 Subject: [PATCH 035/115] update auction query endpoints to remove v1beta1 versioning --- proto/stride/auction/query.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/stride/auction/query.proto b/proto/stride/auction/query.proto index c69cb555f9..856737c7e0 100644 --- a/proto/stride/auction/query.proto +++ b/proto/stride/auction/query.proto @@ -12,12 +12,12 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; service Query { // Auction queries the auction info for a specific token rpc Auction(QueryAuctionRequest) returns (QueryAuctionResponse) { - option (google.api.http).get = "/auction/v1beta1/auction/{denom}"; + option (google.api.http).get = "/auction/auction/{denom}"; } // Auctions queries the auction info for a specific token rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) { - option (google.api.http).get = "/auction/v1beta1/auctions"; + option (google.api.http).get = "/auction/auctions"; } } From ded89569f307b81a3bd73d36fb7e7dbd7b28e12b Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 15:39:23 +0200 Subject: [PATCH 036/115] Refactor x/auction to support multiple token pairs, and add a unique auction name Generalizes auction mechanism to handle any token pair instead of only STRD: - Add unique auction names for better identification - Split token denomination into selling_denom and payment_denom - Rename fields to be more descriptive and token-agnostic - Update message handlers and CLI to support new auction structure --- proto/stride/auction/auction.proto | 28 ++- proto/stride/auction/tx.proto | 42 ++-- x/auction/client/cli/tx.go | 56 ++--- x/auction/keeper/auction_type.go | 38 ++- x/auction/keeper/keeper.go | 16 +- x/auction/keeper/msg_server.go | 25 +- x/auction/types/auction.pb.go | 251 ++++++++++++++------ x/auction/types/genesis.go | 4 +- x/auction/types/keys.go | 4 +- x/auction/types/msgs.go | 54 +++-- x/auction/types/query.pb.go | 22 +- x/auction/types/query.pb.gw.go | 4 +- x/auction/types/tx.pb.go | 363 +++++++++++++++++++---------- 13 files changed, 574 insertions(+), 333 deletions(-) diff --git a/proto/stride/auction/auction.proto b/proto/stride/auction/auction.proto index a088f95981..df9bc73a96 100644 --- a/proto/stride/auction/auction.proto +++ b/proto/stride/auction/auction.proto @@ -18,35 +18,41 @@ message Auction { // Auction type AuctionType type = 1; - // Token denom being auctioned - string denom = 2; + // A unique auction name + string name = 2; + + // Token denom being sold in the auction + string selling_denom = 3; + + // Token denom used to place bids + string payment_denom = 4; // Whether auction is active - bool enabled = 3; + bool enabled = 5; // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 4 [ + string price_multiplier = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // Minimum STRD bid amount - string min_bid_amount = 5 [ + // Minimum payment token bid amount + string min_bid_amount = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // Address to send the auction proceeds to - string beneficiary = 6 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string beneficiary = 8 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Total amount of STRD burned - string total_strd_burned = 7 [ + // Total amount of payment token received + string total_payment_token_received = 9 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; - // Total amount of tokens sold - string total_tokens_sold = 8 [ + // Total amount of selling token sold + string total_selling_token_sold = 10 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; diff --git a/proto/stride/auction/tx.proto b/proto/stride/auction/tx.proto index e2ef2ced0f..0fce1dcc2a 100644 --- a/proto/stride/auction/tx.proto +++ b/proto/stride/auction/tx.proto @@ -29,21 +29,21 @@ service Msg { // MsgPlaceBid defines the message for bidding in a token auction message MsgPlaceBid { option (cosmos.msg.v1.signer) = "bidder"; - option (amino.name) = "stride/x/auction/MsgPlaceBid"; + option (amino.name) = "auction/MsgPlaceBid"; // Bidder's address string bidder = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Token being bid on - string auction_token_denom = 2; + string auction_name = 2; // Amount of tokens requested in base units (utoken) - string auction_token_amount = 3 [ + string selling_token_amount = 3 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; - // Amount of STRD being paid in base units (ustrd) + // Amount of tokens being paid in base units (utoken) string payment_token_amount = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false @@ -55,33 +55,39 @@ message MsgPlaceBidResponse {} // MsgCreateAuction defines the message for adding a token auction message MsgCreateAuction { option (cosmos.msg.v1.signer) = "admin"; - option (amino.name) = "stride/x/auction/MsgCreateAuction"; + option (amino.name) = "auction/MsgCreateAuction"; // Admin's address string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // A unique auction name + string auction_name = 2; + // Auction type - AuctionType auction_type = 2; + AuctionType auction_type = 3; // Denom on Stride of the token being auctioned off (e.g. "ibc/...") - string denom = 3; + string selling_denom = 4; + + // Denom on Stride of the token being used to place bids (e.g. "ustrd") + string payment_denom = 5; // Whether auction is active - bool enabled = 4; + bool enabled = 6; // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 5 [ + string price_multiplier = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // Minimum STRD bid amount - string min_bid_amount = 6 [ + // Minimum payment token bid amount + string min_bid_amount = 8 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; - string beneficiary = 7 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string beneficiary = 9 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } message MsgCreateAuctionResponse {} @@ -89,16 +95,16 @@ message MsgCreateAuctionResponse {} // MsgUpdateAuction defines the message for adding a token auction message MsgUpdateAuction { option (cosmos.msg.v1.signer) = "admin"; - option (amino.name) = "stride/x/auction/MsgUpdateAuction"; + option (amino.name) = "auction/MsgUpdateAuction"; // Admin's address string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Auction type - AuctionType auction_type = 2; + // A unique auction name + string auction_name = 2; - // Denom on Stride of the token being auctioned (e.g. "ibc/...") - string denom = 3; + // Auction type + AuctionType auction_type = 3; // Whether auction is active bool enabled = 4; @@ -109,7 +115,7 @@ message MsgUpdateAuction { (gogoproto.nullable) = false ]; - // Minimum STRD bid amount + // Minimum payment token bid amount string min_bid_amount = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 1fe6b32888..3d297fc5a5 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cobra" @@ -36,13 +35,13 @@ func GetTxCmd() *cobra.Command { func CmdPlaceBid() *cobra.Command { cmd := &cobra.Command{ - Use: "place-bid [utokenAmount] [ustrdAmount]", + Use: "place-bid [auction-name] [selling-token-amount] [payment-token-amount]", Short: "Place a bid on an auction", Long: strings.TrimSpace( fmt.Sprintf(`Place a bid on an auction for a specific token. Example: - $ %[1]s tx %[2]s place-bid 123ibc/DEADBEEF 1000000 --from mykey + $ %[1]s tx %[2]s place-bid auctionName 123 1000000 --from mykey `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(2), @@ -52,21 +51,21 @@ Example: return err } - coin, err := sdk.ParseCoinNormalized(args[0]) + sellingTokenAmount, err := strconv.ParseUint(args[1], 10, 64) if err != nil { - return fmt.Errorf("cannot parse token amount and denom from '%s': %w", args[0], err) + return fmt.Errorf("cannot parse sellingTokenAmount as uint64 from '%s': %w", args[1], err) } - ustrdAmount, err := strconv.ParseUint(args[1], 10, 64) + paymentTokenAmount, err := strconv.ParseUint(args[2], 10, 64) if err != nil { - return fmt.Errorf("cannot parse ustrdAmount as uint64 from '%s': %w", args[2], err) + return fmt.Errorf("cannot parse paymentTokenAmount as uint64 from '%s': %w", args[2], err) } msg := types.NewMsgPlaceBid( clientCtx.GetFromAddress().String(), - coin.Denom, - coin.Amount.Uint64(), - ustrdAmount, + args[0], + sellingTokenAmount, + paymentTokenAmount, ) if err := msg.ValidateBasic(); err != nil { @@ -84,13 +83,13 @@ Example: func CmdCreateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "create-auction [denom] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", + Use: "create-auction [name] [selling-denom] [payment-denom] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", Short: "Create a new auction", Long: strings.TrimSpace( fmt.Sprintf(`Create a new auction for a specific token. Example: - $ %[1]s tx %[2]s create-auction ibc/DEADBEEF true 0.95 1000000 --from admin + $ %[1]s tx %[2]s create-auction my-auction ibc/DEADBEEF true 0.95 1000000 --from admin `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(4), @@ -100,7 +99,7 @@ Example: return err } - enabled := args[1] == "true" + enabled := args[3] == "true" minBidAmount, err := strconv.ParseUint(args[3], 10, 64) if err != nil { @@ -109,12 +108,14 @@ Example: msg := types.NewMsgCreateAuction( clientCtx.GetFromAddress().String(), - types.AuctionType_AUCTION_TYPE_FCFS, // auction type - args[0], // denom - enabled, // enabled - args[2], // price multiplier - minBidAmount, // min bid amount - args[4], // beneficiary + args[0], + types.AuctionType_AUCTION_TYPE_FCFS, + args[1], + args[2], + enabled, + args[4], + minBidAmount, + args[6], ) if err := msg.ValidateBasic(); err != nil { @@ -132,13 +133,13 @@ Example: func CmdUpdateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "update-auction [denom] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", + Use: "update-auction [name] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", Short: "Update an existing auction", Long: strings.TrimSpace( fmt.Sprintf(`Update an existing auction's parameters. Example: - $ %[1]s tx %[2]s update-auction ibc/DEADBEEF true 0.97 500000 --from admin + $ %[1]s tx %[2]s update-auction auctionName true 0.97 500000 --from admin `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(4), @@ -157,13 +158,12 @@ Example: msg := types.NewMsgUpdateAuction( clientCtx.GetFromAddress().String(), - types.AuctionType_AUCTION_TYPE_FCFS, // auction type - args[0], // denom - enabled, // enabled - args[2], // price multiplier - minBidAmount, // min bid amount - args[4], // beneficiary - + args[0], + types.AuctionType_AUCTION_TYPE_FCFS, + enabled, + args[2], + minBidAmount, + args[4], ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index 2422813c20..b7f22d5113 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -20,41 +20,39 @@ var bidHandlers = map[types.AuctionType]AuctionBidHandler{ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *types.MsgPlaceBid) error { // Get token amount being auctioned off moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) - balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.Denom) + balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.SellingDenom) tokenAmountAvailable := balance.Amount // Verify auction has enough tokens to service the bid amount - if bid.AuctionTokenAmount.GT(tokenAmountAvailable) { + if bid.PaymentTokenAmount.GT(tokenAmountAvailable) { return fmt.Errorf("bid wants %s%s but auction has only %s%s", - bid.AuctionTokenAmount.String(), - auction.Denom, + bid.PaymentTokenAmount.String(), + auction.SellingDenom, tokenAmountAvailable.String(), - auction.Denom, + auction.SellingDenom, ) } - paymentTokenDenom := "ustrd" // TODO fix - - price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.Denom, paymentTokenDenom) + price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.SellingDenom, auction.PaymentDenom) if err != nil { return err } discountedPrice := price.Mul(auction.PriceMultiplier) - if bid.AuctionTokenAmount.ToLegacyDec(). + if bid.SellingTokenAmount.ToLegacyDec(). Mul(discountedPrice). LT(bid.PaymentTokenAmount.ToLegacyDec()) { return fmt.Errorf("bid price too low: offered %s%s for %s%s, minimum required is %s%s (price=%s %s/%s)", bid.PaymentTokenAmount.String(), - paymentTokenDenom, - bid.AuctionTokenAmount.String(), - auction.Denom, - bid.AuctionTokenAmount.ToLegacyDec().Mul(discountedPrice).String(), - paymentTokenDenom, + auction.PaymentDenom, + bid.SellingTokenAmount.String(), + auction.SellingDenom, + bid.SellingTokenAmount.ToLegacyDec().Mul(discountedPrice).String(), + auction.PaymentDenom, discountedPrice.String(), - paymentTokenDenom, - auction.Denom, + auction.PaymentDenom, + auction.SellingDenom, ) } @@ -66,7 +64,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type ctx, bidder, sdk.MustAccAddressFromBech32(auction.Beneficiary), - sdk.NewCoins(sdk.NewCoin(paymentTokenDenom, bid.PaymentTokenAmount)), + sdk.NewCoins(sdk.NewCoin(auction.PaymentDenom, bid.PaymentTokenAmount)), ) if err != nil { return fmt.Errorf("failed to send payment tokens from bidder '%s' to beneficiary '%s': %w", @@ -81,7 +79,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type ctx, types.ModuleName, bidder, - sdk.NewCoins(sdk.NewCoin(auction.Denom, bid.AuctionTokenAmount)), + sdk.NewCoins(sdk.NewCoin(auction.SellingDenom, bid.SellingTokenAmount)), ) if err != nil { return fmt.Errorf("failed to send auction tokens from module '%s' to bidder '%s': %w", @@ -91,8 +89,8 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type ) } - auction.TotalTokensSold = auction.TotalTokensSold.Add(bid.AuctionTokenAmount) - auction.TotalStrdBurned = auction.TotalStrdBurned.Add(bid.PaymentTokenAmount) + auction.TotalSellingTokenSold = auction.TotalSellingTokenSold.Add(bid.SellingTokenAmount) + auction.TotalPaymentTokenReceived = auction.TotalPaymentTokenReceived.Add(bid.PaymentTokenAmount) err = k.SetAuction(ctx, auction) if err != nil { diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 5a1e8dee7c..91f62951ce 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -43,10 +43,10 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // SetAuction stores auction info for a token func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { store := ctx.KVStore(k.storeKey) - key := types.AuctionKey(auction.Denom) + key := types.AuctionKey(auction.Name) bz, err := k.cdc.Marshal(auction) if err != nil { - return fmt.Errorf("error setting auction for denom '%s': %w", auction.Denom, err) + return fmt.Errorf("error setting auction for name='%s': %w", auction.Name, err) } store.Set(key, bz) @@ -54,18 +54,18 @@ func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { } // GetAuction retrieves auction info for a token -func (k Keeper) GetAuction(ctx sdk.Context, denom string) (*types.Auction, error) { +func (k Keeper) GetAuction(ctx sdk.Context, name string) (*types.Auction, error) { store := ctx.KVStore(k.storeKey) - key := types.AuctionKey(denom) + key := types.AuctionKey(name) bz := store.Get(key) if bz == nil { - return &types.Auction{}, fmt.Errorf("auction not found for denom '%s'", denom) + return &types.Auction{}, fmt.Errorf("auction not found for denom '%s'", name) } var auction types.Auction if err := k.cdc.Unmarshal(bz, &auction); err != nil { - return &types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.Denom, err) + return &types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.SellingDenom, err) } return &auction, nil @@ -90,9 +90,9 @@ func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { // PlaceBid places an auction bid and executes it based on the auction type func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { // Get auction - auction, err := k.GetAuction(ctx, bid.AuctionTokenDenom) + auction, err := k.GetAuction(ctx, bid.AuctionName) if err != nil { - return fmt.Errorf("cannot get auction for denom='%s': %w", bid.AuctionTokenDenom, err) + return fmt.Errorf("cannot get auction for name='%s': %w", bid.AuctionName, err) } // Get the appropriate auctionBidHandler for the auction type diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 28ffa69513..cd81c8c061 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Stride-Labs/stride/v24/x/auction/types" @@ -38,18 +39,22 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc // TODO check admin - _, err := ms.Keeper.GetAuction(ctx, msg.Denom) + _, err := ms.Keeper.GetAuction(ctx, msg.AuctionName) if err == nil { - return nil, types.ErrAuctionAlreadyExists.Wrapf("auction for token '%s' already exists", msg.Denom) + return nil, types.ErrAuctionAlreadyExists.Wrapf("auction with name '%s' already exists", msg.AuctionName) } auction := types.Auction{ - Type: msg.AuctionType, - Denom: msg.Denom, - Enabled: msg.Enabled, - PriceMultiplier: msg.PriceMultiplier, - MinBidAmount: msg.MinBidAmount, - Beneficiary: msg.Beneficiary, + Type: msg.AuctionType, + Name: msg.AuctionName, + SellingDenom: msg.SellingDenom, + PaymentDenom: msg.PaymentDenom, + Enabled: msg.Enabled, + PriceMultiplier: msg.PriceMultiplier, + MinBidAmount: msg.MinBidAmount, + Beneficiary: msg.Beneficiary, + TotalPaymentTokenReceived: math.ZeroInt(), + TotalSellingTokenSold: math.ZeroInt(), } err = ms.Keeper.SetAuction(ctx, &auction) @@ -66,9 +71,9 @@ func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuc // TODO check admin - auction, err := ms.Keeper.GetAuction(ctx, msg.Denom) + auction, err := ms.Keeper.GetAuction(ctx, msg.AuctionName) if err != nil { - return nil, types.ErrAuctionDoesntExist.Wrapf("cannot find auction for token '%s'", msg.Denom) + return nil, types.ErrAuctionDoesntExist.Wrapf("cannot find auction with name '%s'", msg.AuctionName) } auction.Type = msg.AuctionType diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index 779201577d..85a2d12caf 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -91,20 +91,24 @@ var xxx_messageInfo_Params proto.InternalMessageInfo type Auction struct { // Auction type Type AuctionType `protobuf:"varint,1,opt,name=type,proto3,enum=stride.auction.AuctionType" json:"type,omitempty"` - // Token denom being auctioned - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + // A unique auction name + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Token denom being sold in the auction + SellingDenom string `protobuf:"bytes,3,opt,name=selling_denom,json=sellingDenom,proto3" json:"selling_denom,omitempty"` + // Token denom used to place bids + PaymentDenom string `protobuf:"bytes,4,opt,name=payment_denom,json=paymentDenom,proto3" json:"payment_denom,omitempty"` // Whether auction is active - Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,5,opt,name=enabled,proto3" json:"enabled,omitempty"` // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` - // Minimum STRD bid amount - MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum payment token bid amount + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` // Address to send the auction proceeds to - Beneficiary string `protobuf:"bytes,6,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` - // Total amount of STRD burned - TotalStrdBurned cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=total_strd_burned,json=totalStrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_strd_burned"` - // Total amount of tokens sold - TotalTokensSold cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=total_tokens_sold,json=totalTokensSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_tokens_sold"` + Beneficiary string `protobuf:"bytes,8,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` + // Total amount of payment token received + TotalPaymentTokenReceived cosmossdk_io_math.Int `protobuf:"bytes,9,opt,name=total_payment_token_received,json=totalPaymentTokenReceived,proto3,customtype=cosmossdk.io/math.Int" json:"total_payment_token_received"` + // Total amount of selling token sold + TotalSellingTokenSold cosmossdk_io_math.Int `protobuf:"bytes,10,opt,name=total_selling_token_sold,json=totalSellingTokenSold,proto3,customtype=cosmossdk.io/math.Int" json:"total_selling_token_sold"` } func (m *Auction) Reset() { *m = Auction{} } @@ -147,9 +151,23 @@ func (m *Auction) GetType() AuctionType { return AuctionType_AUCTION_TYPE_UNSPECIFIED } -func (m *Auction) GetDenom() string { +func (m *Auction) GetName() string { if m != nil { - return m.Denom + return m.Name + } + return "" +} + +func (m *Auction) GetSellingDenom() string { + if m != nil { + return m.SellingDenom + } + return "" +} + +func (m *Auction) GetPaymentDenom() string { + if m != nil { + return m.PaymentDenom } return "" } @@ -177,37 +195,40 @@ func init() { func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_739480caccbf7be9) } var fileDescriptor_739480caccbf7be9 = []byte{ - // 472 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x6e, 0xd3, 0x30, - 0x18, 0xc7, 0x1b, 0xb6, 0xb5, 0xc5, 0x43, 0x5d, 0x67, 0x75, 0x92, 0xd9, 0x46, 0x56, 0x8d, 0x4b, - 0x85, 0xb4, 0x44, 0x0c, 0x4e, 0xdc, 0xda, 0xae, 0x95, 0x22, 0x46, 0xa9, 0x92, 0xee, 0x00, 0x97, - 0xc8, 0x89, 0x4d, 0x66, 0x2d, 0xb1, 0x23, 0xdb, 0x41, 0xf4, 0x2d, 0x78, 0x18, 0x1e, 0x62, 0xc7, - 0xc1, 0x09, 0x71, 0x98, 0x50, 0xfb, 0x22, 0xa8, 0x4e, 0x36, 0x36, 0xed, 0xb2, 0x53, 0xf2, 0x7d, - 0xdf, 0xff, 0xff, 0xf3, 0x27, 0xfb, 0x0f, 0xf6, 0x95, 0x96, 0x8c, 0x50, 0x17, 0x17, 0xb1, 0x66, - 0x82, 0xdf, 0x7c, 0x9d, 0x5c, 0x0a, 0x2d, 0x60, 0xab, 0x9c, 0x3a, 0x55, 0x77, 0xf7, 0x79, 0x2c, - 0x54, 0x26, 0x54, 0x68, 0xa6, 0x6e, 0x59, 0x94, 0xd2, 0xdd, 0x4e, 0x22, 0x12, 0x51, 0xf6, 0x57, - 0x7f, 0x65, 0xf7, 0xb0, 0x09, 0xea, 0x53, 0x2c, 0x71, 0xa6, 0x0e, 0x7f, 0xae, 0x81, 0x46, 0xbf, - 0xc4, 0x40, 0x17, 0x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0xb3, 0xc3, 0x96, 0xf1, 0x05, 0x5a, - 0x92, 0x81, 0x71, 0xfd, 0x47, 0x69, 0x71, 0x41, 0xb9, 0x0a, 0x95, 0x48, 0x09, 0x6a, 0x3e, 0x1e, - 0x35, 0x33, 0xb6, 0x40, 0xa4, 0xe4, 0xd5, 0x00, 0x6c, 0xde, 0x79, 0x2b, 0xb8, 0x0f, 0x50, 0xff, - 0x6c, 0x38, 0xf3, 0x3e, 0x4e, 0xc2, 0xd9, 0xa7, 0xe9, 0x28, 0x3c, 0x9b, 0x04, 0xd3, 0xd1, 0xd0, - 0x1b, 0x7b, 0xa3, 0x93, 0x76, 0x0d, 0xee, 0x80, 0xed, 0x7b, 0xd3, 0xf1, 0x70, 0x1c, 0xb4, 0xad, - 0xc1, 0xfb, 0xcb, 0x85, 0x6d, 0x5d, 0x2d, 0x6c, 0xeb, 0xef, 0xc2, 0xb6, 0xbe, 0x2f, 0xed, 0xda, - 0xd5, 0xd2, 0xae, 0xfd, 0x5e, 0xda, 0xb5, 0xcf, 0xaf, 0x13, 0xa6, 0xcf, 0x8b, 0xc8, 0x89, 0x45, - 0xe6, 0x06, 0x26, 0x21, 0x47, 0xa7, 0x38, 0x52, 0x6e, 0x95, 0xd8, 0xaf, 0xc7, 0x6f, 0xdd, 0x6f, - 0xb7, 0xb9, 0x5d, 0xc5, 0x44, 0x45, 0x75, 0x93, 0xba, 0x37, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x3b, 0xba, 0x22, 0x15, 0xd6, 0x02, 0x00, 0x00, + // 519 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x1b, 0x28, 0xfb, 0xe3, 0x8d, 0x52, 0xac, 0x55, 0xf2, 0xb6, 0x92, 0x55, 0xdb, 0xa5, + 0x42, 0x5a, 0x22, 0x06, 0x27, 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x5f, 0x76, 0xc1, 0xd6, 0x9d, 0xae, 0x80, 0x4d, 0x80, 0x3a, 0x67, 0xbd, + 0xe9, 0xe8, 0xc3, 0x38, 0x98, 0x7e, 0x9a, 0x0c, 0x82, 0xb3, 0xb1, 0x3f, 0x19, 0xf4, 0x46, 0xc3, + 0xd1, 0xa0, 0x5f, 0xaf, 0xc0, 0x06, 0x78, 0x7e, 0xaf, 0x3a, 0xec, 0x0d, 0xfd, 0xba, 0xd5, 0x7d, + 0x77, 0xb5, 0xb0, 0xad, 0xeb, 0x85, 0x6d, 0xfd, 0x5d, 0xd8, 0xd6, 0xf7, 0xa5, 0x5d, 0xb9, 0x5e, + 0xda, 0x95, 0xdf, 0x4b, 0xbb, 0xf2, 0xf9, 0x55, 0x42, 0xd5, 0xf9, 0x2c, 0x74, 0x22, 0xc1, 0x5c, + 0x5f, 0xf7, 0xe2, 0xf1, 0x29, 0x0e, 0xa5, 0x5b, 0xce, 0xc6, 0xe5, 0xc9, 0x1b, 0xf7, 0xdb, 0xed, + 0x84, 0x14, 0x0d, 0x29, 0xc3, 0x35, 0xdd, 0xdf, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x7c, + 0xb8, 0x16, 0x97, 0x40, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -254,31 +275,31 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.TotalTokensSold.Size() + size := m.TotalSellingTokenSold.Size() i -= size - if _, err := m.TotalTokensSold.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.TotalSellingTokenSold.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x52 { - size := m.TotalStrdBurned.Size() + size := m.TotalPaymentTokenReceived.Size() i -= size - if _, err := m.TotalStrdBurned.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.TotalPaymentTokenReceived.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x4a if len(m.Beneficiary) > 0 { i -= len(m.Beneficiary) copy(dAtA[i:], m.Beneficiary) i = encodeVarintAuction(dAtA, i, uint64(len(m.Beneficiary))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x42 } { size := m.MinBidAmount.Size() @@ -289,7 +310,7 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a { size := m.PriceMultiplier.Size() i -= size @@ -299,7 +320,7 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAuction(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 if m.Enabled { i-- if m.Enabled { @@ -308,12 +329,26 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x28 } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintAuction(dAtA, i, uint64(len(m.Denom))) + if len(m.PaymentDenom) > 0 { + i -= len(m.PaymentDenom) + copy(dAtA[i:], m.PaymentDenom) + i = encodeVarintAuction(dAtA, i, uint64(len(m.PaymentDenom))) + i-- + dAtA[i] = 0x22 + } + if len(m.SellingDenom) > 0 { + i -= len(m.SellingDenom) + copy(dAtA[i:], m.SellingDenom) + i = encodeVarintAuction(dAtA, i, uint64(len(m.SellingDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintAuction(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0x12 } @@ -354,7 +389,15 @@ func (m *Auction) Size() (n int) { if m.Type != 0 { n += 1 + sovAuction(uint64(m.Type)) } - l = len(m.Denom) + l = len(m.Name) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = len(m.SellingDenom) + if l > 0 { + n += 1 + l + sovAuction(uint64(l)) + } + l = len(m.PaymentDenom) if l > 0 { n += 1 + l + sovAuction(uint64(l)) } @@ -369,9 +412,9 @@ func (m *Auction) Size() (n int) { if l > 0 { n += 1 + l + sovAuction(uint64(l)) } - l = m.TotalStrdBurned.Size() + l = m.TotalPaymentTokenReceived.Size() n += 1 + l + sovAuction(uint64(l)) - l = m.TotalTokensSold.Size() + l = m.TotalSellingTokenSold.Size() n += 1 + l + sovAuction(uint64(l)) return n } @@ -482,7 +525,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -510,9 +553,73 @@ func (m *Auction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SellingDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SellingDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PaymentDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuction + } + 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 ErrInvalidLengthAuction + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuction + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PaymentDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } @@ -532,7 +639,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } } m.Enabled = bool(v != 0) - case 4: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) } @@ -566,7 +673,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) } @@ -600,7 +707,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) } @@ -632,9 +739,9 @@ func (m *Auction) Unmarshal(dAtA []byte) error { } m.Beneficiary = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalStrdBurned", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalPaymentTokenReceived", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -662,13 +769,13 @@ func (m *Auction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalStrdBurned.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalPaymentTokenReceived.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 8: + case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalTokensSold", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalSellingTokenSold", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -696,7 +803,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.TotalTokensSold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalSellingTokenSold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go index 4b8d1f6bb3..53b631d90f 100644 --- a/x/auction/types/genesis.go +++ b/x/auction/types/genesis.go @@ -16,8 +16,10 @@ func (gs GenesisState) Validate() error { msg := NewMsgCreateAuction( "stride16eenchewedupsplt0ut600ed0ffstageeeervs", // dummy address, not stored in auction + auction.Name, auction.Type, - auction.Denom, + auction.SellingDenom, + auction.PaymentDenom, auction.Enabled, auction.PriceMultiplier.String(), auction.MinBidAmount.Uint64(), diff --git a/x/auction/types/keys.go b/x/auction/types/keys.go index 30f31af010..c9d169fbf0 100644 --- a/x/auction/types/keys.go +++ b/x/auction/types/keys.go @@ -15,6 +15,6 @@ const ( KeyAuctionPrefix = "auction" ) -func AuctionKey(denom string) []byte { - return []byte(fmt.Sprintf("%s%s", KeyAuctionPrefix, denom)) +func AuctionKey(auctionName string) []byte { + return []byte(fmt.Sprintf("%s|%s", KeyAuctionPrefix, auctionName)) } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 313601eecb..0797b72d07 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -34,14 +34,14 @@ var ( func NewMsgPlaceBid( bidder string, - tokenDenom string, - auctionTokenAmount uint64, + AuctionName string, + sellingTokenAmount uint64, paymentTokenAmount uint64, ) *MsgPlaceBid { return &MsgPlaceBid{ Bidder: bidder, - AuctionTokenDenom: tokenDenom, - AuctionTokenAmount: math.NewIntFromUint64(auctionTokenAmount), + AuctionName: AuctionName, + SellingTokenAmount: math.NewIntFromUint64(sellingTokenAmount), PaymentTokenAmount: math.NewIntFromUint64(paymentTokenAmount), } } @@ -71,14 +71,14 @@ func (msg *MsgPlaceBid) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Bidder); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } - if msg.AuctionTokenDenom == "" { - return errors.New("token-denom must be specified") + if msg.AuctionName == "" { + return errors.New("auction-name must be specified") } - if msg.AuctionTokenAmount.IsZero() { - return errors.New("utoken-amount cannot be 0") + if msg.SellingTokenAmount.IsZero() { + return errors.New("selling-token-amount cannot be 0") } if msg.PaymentTokenAmount.IsZero() { - return errors.New("ustrd-amount cannot be 0") + return errors.New("payment-token-amount cannot be 0") } return nil @@ -90,8 +90,10 @@ func (msg *MsgPlaceBid) ValidateBasic() error { func NewMsgCreateAuction( admin string, + auctionName string, auctionType AuctionType, - denom string, + sellingDenom string, + paymentDenom string, enabled bool, priceMultiplier string, minBidAmount uint64, @@ -104,8 +106,10 @@ func NewMsgCreateAuction( return &MsgCreateAuction{ Admin: admin, + AuctionName: auctionName, AuctionType: auctionType, - Denom: denom, + SellingDenom: sellingDenom, + PaymentDenom: paymentDenom, Enabled: enabled, PriceMultiplier: priceMultiplierDec, MinBidAmount: math.NewIntFromUint64(minBidAmount), @@ -138,18 +142,24 @@ func (msg *MsgCreateAuction) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid admin address (%s)", err) } + if msg.AuctionName == "" { + return errors.New("auction-name must be specified") + } if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { return fmt.Errorf("auction-type %d is invalid", msg.AuctionType) } - if msg.Denom == "" { - return errors.New("denom must be specified") + if msg.SellingDenom == "" { + return errors.New("selling-denom must be specified") } - if msg.MinBidAmount.LT(math.ZeroInt()) { - return errors.New("min-bid-amount must be >= 0") + if msg.PaymentDenom == "" { + return errors.New("payment-denom must be specified") } if !(msg.PriceMultiplier.GT(math.LegacyZeroDec()) && msg.PriceMultiplier.LTE(math.LegacyOneDec())) { return errors.New("price-multiplier must be > 0 and <= 1 (0 > priceMultiplier >= 1)") } + if msg.MinBidAmount.LT(math.ZeroInt()) { + return errors.New("min-bid-amount must be >= 0") + } if _, err := sdk.AccAddressFromBech32(msg.Beneficiary); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid beneficiary address (%s)", err) } @@ -163,8 +173,8 @@ func (msg *MsgCreateAuction) ValidateBasic() error { func NewMsgUpdateAuction( admin string, + auctionName string, auctionType AuctionType, - denom string, enabled bool, priceMultiplier string, minBidAmount uint64, @@ -177,8 +187,8 @@ func NewMsgUpdateAuction( return &MsgUpdateAuction{ Admin: admin, + AuctionName: auctionName, AuctionType: auctionType, - Denom: denom, Enabled: enabled, PriceMultiplier: priceMultiplierDec, MinBidAmount: math.NewIntFromUint64(minBidAmount), @@ -211,18 +221,18 @@ func (msg *MsgUpdateAuction) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } + if msg.AuctionName == "" { + return errors.New("auction-name must be specified") + } if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { return errors.New("auction-type is invalid") } - if msg.Denom == "" { - return errors.New("denom must be specified") + if msg.PriceMultiplier.IsZero() { + return errors.New("price-multiplier cannot be 0") } if msg.MinBidAmount.LT(math.ZeroInt()) { return errors.New("min-bid-amount must be at least 0") } - if msg.PriceMultiplier.IsZero() { - return errors.New("price-multiplier cannot be 0") - } if _, err := sdk.AccAddressFromBech32(msg.Beneficiary); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) } diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index b4c6e7f8d2..c6f6e33b0e 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -232,7 +232,7 @@ func init() { func init() { proto.RegisterFile("stride/auction/query.proto", fileDescriptor_8113674a9412675c) } var fileDescriptor_8113674a9412675c = []byte{ - // 431 bytes of a gzipped FileDescriptorProto + // 428 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x2e, 0x29, 0xca, 0x4c, 0x49, 0xd5, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xc8, 0xe9, 0x41, 0xe5, 0xa4, 0xb4, 0x92, @@ -250,16 +250,16 @@ var fileDescriptor_8113674a9412675c = []byte{ 0xd3, 0x53, 0xa1, 0x7a, 0x83, 0x90, 0x74, 0x2a, 0xcd, 0x66, 0xe4, 0x12, 0x45, 0xb3, 0x00, 0xea, 0x64, 0x4b, 0x2e, 0x0e, 0xa8, 0x23, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x09, 0xbb, 0x19, 0xae, 0x5c, 0xc8, 0x1d, 0xc5, 0x71, 0x4c, 0x60, 0xc7, 0xa9, 0x13, 0x74, 0x1c, 0xc4, 0x5e, 0x64, 0xd7, 0x19, - 0x35, 0x33, 0x71, 0xb1, 0x82, 0x5d, 0x27, 0x54, 0xc7, 0xc5, 0x0e, 0xb5, 0x4d, 0x48, 0x19, 0xdd, - 0x19, 0x58, 0xa2, 0x47, 0x4a, 0x05, 0xbf, 0x22, 0x88, 0x5d, 0x4a, 0x1a, 0x4d, 0x97, 0x9f, 0x4c, - 0x66, 0x52, 0x12, 0x52, 0x80, 0xc7, 0x3d, 0x2c, 0x61, 0xc1, 0xf8, 0xd5, 0xe0, 0x78, 0xad, 0x15, - 0xaa, 0xe2, 0xe2, 0x80, 0x85, 0x90, 0x10, 0x5e, 0xb3, 0x61, 0x31, 0x24, 0xa5, 0x4a, 0x40, 0x15, - 0xd4, 0x09, 0x8a, 0x60, 0x27, 0x48, 0x0b, 0x49, 0xe2, 0x72, 0x42, 0xb1, 0x93, 0xf7, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, - 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, - 0x25, 0xe7, 0xe7, 0xea, 0x07, 0x83, 0x6d, 0xd3, 0xf5, 0x49, 0x4c, 0x2a, 0xd6, 0x87, 0x26, 0xe8, - 0x32, 0x23, 0x13, 0xfd, 0x0a, 0xb8, 0xb9, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x54, - 0x6d, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x44, 0x3c, 0x54, 0x81, 0x03, 0x00, 0x00, + 0x7d, 0x66, 0xe4, 0x62, 0x05, 0xbb, 0x4e, 0xa8, 0x8c, 0x8b, 0x1d, 0x6a, 0x9b, 0x90, 0x32, 0xba, + 0x33, 0xb0, 0x44, 0x8f, 0x94, 0x0a, 0x7e, 0x45, 0x10, 0xbb, 0x94, 0x14, 0x9a, 0x2e, 0x3f, 0x99, + 0xcc, 0x24, 0x25, 0x24, 0x81, 0x1e, 0xf7, 0xfa, 0xd5, 0xe0, 0xf8, 0xac, 0x15, 0x2a, 0xe2, 0xe2, + 0x80, 0x85, 0x8c, 0x10, 0x5e, 0x33, 0x61, 0x31, 0x23, 0xa5, 0x4a, 0x40, 0x15, 0xd4, 0x6a, 0x49, + 0xb0, 0xd5, 0xc2, 0x42, 0x82, 0xe8, 0x56, 0x17, 0x3b, 0x79, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, + 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, + 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x61, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, + 0x7e, 0x30, 0xd8, 0x16, 0x5d, 0x9f, 0xc4, 0xa4, 0x62, 0x7d, 0x68, 0x02, 0x2e, 0x33, 0x32, 0xd1, + 0xaf, 0x80, 0x9b, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0xc5, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xc5, 0xc2, 0xaf, 0xf1, 0x71, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/auction/types/query.pb.gw.go b/x/auction/types/query.pb.gw.go index f29fad68a3..59bb1faabd 100644 --- a/x/auction/types/query.pb.gw.go +++ b/x/auction/types/query.pb.gw.go @@ -260,9 +260,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0, 1, 0, 4, 1, 5, 2}, []string{"auction", "v1beta1", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 0, 1, 0, 4, 1, 5, 1}, []string{"auction", "denom"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auction", "v1beta1", "auctions"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auction", "auctions"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index debcc1eb5c..7398a6e778 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -37,10 +37,10 @@ type MsgPlaceBid struct { // Bidder's address Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` // Token being bid on - AuctionTokenDenom string `protobuf:"bytes,2,opt,name=auction_token_denom,json=auctionTokenDenom,proto3" json:"auction_token_denom,omitempty"` + AuctionName string `protobuf:"bytes,2,opt,name=auction_name,json=auctionName,proto3" json:"auction_name,omitempty"` // Amount of tokens requested in base units (utoken) - AuctionTokenAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=auction_token_amount,json=auctionTokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"auction_token_amount"` - // Amount of STRD being paid in base units (ustrd) + SellingTokenAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=selling_token_amount,json=sellingTokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"selling_token_amount"` + // Amount of tokens being paid in base units (utoken) PaymentTokenAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=payment_token_amount,json=paymentTokenAmount,proto3,customtype=cosmossdk.io/math.Int" json:"payment_token_amount"` } @@ -84,9 +84,9 @@ func (m *MsgPlaceBid) GetBidder() string { return "" } -func (m *MsgPlaceBid) GetAuctionTokenDenom() string { +func (m *MsgPlaceBid) GetAuctionName() string { if m != nil { - return m.AuctionTokenDenom + return m.AuctionName } return "" } @@ -131,17 +131,21 @@ var xxx_messageInfo_MsgPlaceBidResponse proto.InternalMessageInfo type MsgCreateAuction struct { // Admin's address Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // A unique auction name + AuctionName string `protobuf:"bytes,2,opt,name=auction_name,json=auctionName,proto3" json:"auction_name,omitempty"` // Auction type - AuctionType AuctionType `protobuf:"varint,2,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` + AuctionType AuctionType `protobuf:"varint,3,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` // Denom on Stride of the token being auctioned off (e.g. "ibc/...") - Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` + SellingDenom string `protobuf:"bytes,4,opt,name=selling_denom,json=sellingDenom,proto3" json:"selling_denom,omitempty"` + // Denom on Stride of the token being used to place bids (e.g. "ustrd") + PaymentDenom string `protobuf:"bytes,5,opt,name=payment_denom,json=paymentDenom,proto3" json:"payment_denom,omitempty"` // Whether auction is active - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,6,opt,name=enabled,proto3" json:"enabled,omitempty"` // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` - // Minimum STRD bid amount - MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` - Beneficiary string `protobuf:"bytes,7,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` + PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum payment token bid amount + MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` + Beneficiary string `protobuf:"bytes,9,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` } func (m *MsgCreateAuction) Reset() { *m = MsgCreateAuction{} } @@ -184,6 +188,13 @@ func (m *MsgCreateAuction) GetAdmin() string { return "" } +func (m *MsgCreateAuction) GetAuctionName() string { + if m != nil { + return m.AuctionName + } + return "" +} + func (m *MsgCreateAuction) GetAuctionType() AuctionType { if m != nil { return m.AuctionType @@ -191,9 +202,16 @@ func (m *MsgCreateAuction) GetAuctionType() AuctionType { return AuctionType_AUCTION_TYPE_UNSPECIFIED } -func (m *MsgCreateAuction) GetDenom() string { +func (m *MsgCreateAuction) GetSellingDenom() string { + if m != nil { + return m.SellingDenom + } + return "" +} + +func (m *MsgCreateAuction) GetPaymentDenom() string { if m != nil { - return m.Denom + return m.PaymentDenom } return "" } @@ -252,15 +270,15 @@ var xxx_messageInfo_MsgCreateAuctionResponse proto.InternalMessageInfo type MsgUpdateAuction struct { // Admin's address Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // A unique auction name + AuctionName string `protobuf:"bytes,2,opt,name=auction_name,json=auctionName,proto3" json:"auction_name,omitempty"` // Auction type - AuctionType AuctionType `protobuf:"varint,2,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` - // Denom on Stride of the token being auctioned (e.g. "ibc/...") - Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` + AuctionType AuctionType `protobuf:"varint,3,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` // Price multiplier (e.g. 0.95 for 5% discount) PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` - // Minimum STRD bid amount + // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` Beneficiary string `protobuf:"bytes,7,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` } @@ -305,18 +323,18 @@ func (m *MsgUpdateAuction) GetAdmin() string { return "" } -func (m *MsgUpdateAuction) GetAuctionType() AuctionType { +func (m *MsgUpdateAuction) GetAuctionName() string { if m != nil { - return m.AuctionType + return m.AuctionName } - return AuctionType_AUCTION_TYPE_UNSPECIFIED + return "" } -func (m *MsgUpdateAuction) GetDenom() string { +func (m *MsgUpdateAuction) GetAuctionType() AuctionType { if m != nil { - return m.Denom + return m.AuctionType } - return "" + return AuctionType_AUCTION_TYPE_UNSPECIFIED } func (m *MsgUpdateAuction) GetEnabled() bool { @@ -381,47 +399,50 @@ func init() { func init() { proto.RegisterFile("stride/auction/tx.proto", fileDescriptor_07b888fb549a7ca8) } var fileDescriptor_07b888fb549a7ca8 = []byte{ - // 634 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xb1, 0x53, 0xd4, 0x40, - 0x14, 0xc6, 0xef, 0xc0, 0x03, 0x5c, 0x10, 0x61, 0x39, 0x86, 0x18, 0x34, 0xe0, 0xd1, 0x30, 0x8c, - 0x24, 0x80, 0x56, 0x14, 0xce, 0x70, 0xd0, 0x38, 0x72, 0xea, 0x04, 0x6c, 0xb4, 0xb8, 0xd9, 0x64, - 0xd7, 0xb0, 0xc3, 0xed, 0x6e, 0x26, 0xbb, 0xc7, 0x70, 0x9d, 0x63, 0x69, 0x65, 0xe1, 0x1f, 0x42, - 0xa1, 0xb5, 0x2d, 0x25, 0x63, 0xe5, 0x58, 0x30, 0x0e, 0x14, 0xfc, 0x1b, 0x4e, 0xb2, 0x7b, 0x67, - 0x02, 0x37, 0x42, 0x69, 0x61, 0x73, 0xb9, 0xb7, 0xdf, 0x7b, 0xdf, 0xe6, 0xbe, 0xdf, 0xe6, 0x02, - 0x66, 0xa4, 0x4a, 0x28, 0x26, 0x1e, 0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, 0x79, 0x7d, 0x25, 0x45, 0xa9, 0xc3, 0x4c, 0x49, 0x3e, 0xec, 0x47, 0xb2, - 0x80, 0xa8, 0x66, 0x03, 0xeb, 0xf2, 0xda, 0x65, 0xa6, 0xaf, 0x63, 0xfc, 0x9f, 0xe9, 0xbf, 0xcd, - 0xb4, 0x80, 0xc8, 0x30, 0x2d, 0xac, 0x75, 0x99, 0xae, 0x7d, 0x1e, 0x00, 0x83, 0x0d, 0x19, 0xc1, - 0x6d, 0x30, 0xd2, 0xfb, 0x13, 0xbc, 0x02, 0x23, 0xf7, 0x80, 0xdb, 0x0b, 0x7f, 0x11, 0xbb, 0xae, - 0xf0, 0x2d, 0xb8, 0x53, 0x7c, 0xf2, 0xe7, 0xfb, 0x4c, 0x15, 0x3a, 0xec, 0xc5, 0xeb, 0x3a, 0xf2, - 0xe6, 0xc5, 0x23, 0xd8, 0xcf, 0xbc, 0xd0, 0xd1, 0xd7, 0xbc, 0x6f, 0x1e, 0x76, 0xe5, 0xfd, 0xc5, - 0xd1, 0x52, 0xb9, 0xfe, 0xfc, 0xf8, 0xcc, 0x29, 0x9f, 0x9c, 0x39, 0xe5, 0x5f, 0x67, 0x4e, 0xf9, - 0xd3, 0xb9, 0x53, 0x3a, 0x39, 0x77, 0x4a, 0x3f, 0xce, 0x9d, 0xd2, 0x9b, 0xd5, 0x88, 0xaa, 0xbd, - 0x76, 0xe0, 0x86, 0x82, 0x79, 0x3b, 0x99, 0xe9, 0xf2, 0x36, 0x0a, 0xa4, 0x67, 0x30, 0x1c, 0xac, - 0x3d, 0xc9, 0xa1, 0x48, 0x4f, 0xb8, 0x0c, 0x86, 0xb2, 0x77, 0xcd, 0xe3, 0xdf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x2c, 0x09, 0x39, 0xd9, 0x11, 0x07, 0x00, 0x00, + // 683 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc,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30, 0xd2, 0x3d, 0x40, 0x6f, 0xb8, 0x9d, 0x39, 0x32, 0xca, 0xb5, 0xdf, 0x0c, 0x53, 0x55, 0xf3, + 0x35, 0x98, 0xc8, 0x9f, 0x25, 0x8b, 0x3d, 0x58, 0x39, 0x44, 0x79, 0xa9, 0x1f, 0x22, 0x2b, 0x9e, + 0x5f, 0xc3, 0x5e, 0xe2, 0x39, 0x44, 0x4f, 0xf1, 0x9e, 0x7e, 0x94, 0x8b, 0x6f, 0x2f, 0x8f, 0x97, + 0x8d, 0xfa, 0xb3, 0x93, 0xf3, 0x8a, 0x71, 0x7a, 0x5e, 0x31, 0x7e, 0x9e, 0x57, 0x8c, 0x8f, 0x17, + 0x95, 0xc2, 0xe9, 0x45, 0xa5, 0xf0, 0xfd, 0xa2, 0x52, 0x78, 0xb5, 0x1a, 0x10, 0xb9, 0xdf, 0xf6, + 0x6c, 0x9f, 0x53, 0x67, 0x37, 0x11, 0x5d, 0xd9, 0x86, 0x9e, 0x70, 0xf4, 0x15, 0x75, 0xb8, 0xf6, + 0xd8, 0x39, 0xba, 0xba, 0x2e, 0x3b, 0x21, 0x16, 0x5e, 0x29, 0xb9, 0xa7, 0x1e, 0xfd, 0x0a, 0x00, + 0x00, 0xff, 0xff, 0x36, 0x84, 0x29, 0x71, 0x4d, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -613,19 +634,19 @@ func (m *MsgPlaceBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 { - size := m.AuctionTokenAmount.Size() + size := m.SellingTokenAmount.Size() i -= size - if _, err := m.AuctionTokenAmount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.SellingTokenAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a - if len(m.AuctionTokenDenom) > 0 { - i -= len(m.AuctionTokenDenom) - copy(dAtA[i:], m.AuctionTokenDenom) - i = encodeVarintTx(dAtA, i, uint64(len(m.AuctionTokenDenom))) + if len(m.AuctionName) > 0 { + i -= len(m.AuctionName) + copy(dAtA[i:], m.AuctionName) + i = encodeVarintTx(dAtA, i, uint64(len(m.AuctionName))) i-- dAtA[i] = 0x12 } @@ -687,7 +708,7 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Beneficiary) i = encodeVarintTx(dAtA, i, uint64(len(m.Beneficiary))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x4a } { size := m.MinBidAmount.Size() @@ -698,7 +719,7 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x42 { size := m.PriceMultiplier.Size() i -= size @@ -708,7 +729,7 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a if m.Enabled { i-- if m.Enabled { @@ -717,19 +738,33 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x20 + dAtA[i] = 0x30 + } + if len(m.PaymentDenom) > 0 { + i -= len(m.PaymentDenom) + copy(dAtA[i:], m.PaymentDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.PaymentDenom))) + i-- + dAtA[i] = 0x2a } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + if len(m.SellingDenom) > 0 { + i -= len(m.SellingDenom) + copy(dAtA[i:], m.SellingDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.SellingDenom))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if m.AuctionType != 0 { i = encodeVarintTx(dAtA, i, uint64(m.AuctionType)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 + } + if len(m.AuctionName) > 0 { + i -= len(m.AuctionName) + copy(dAtA[i:], m.AuctionName) + i = encodeVarintTx(dAtA, i, uint64(len(m.AuctionName))) + i-- + dAtA[i] = 0x12 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -821,17 +856,17 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x1a - } if m.AuctionType != 0 { i = encodeVarintTx(dAtA, i, uint64(m.AuctionType)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 + } + if len(m.AuctionName) > 0 { + i -= len(m.AuctionName) + copy(dAtA[i:], m.AuctionName) + i = encodeVarintTx(dAtA, i, uint64(len(m.AuctionName))) + i-- + dAtA[i] = 0x12 } if len(m.Admin) > 0 { i -= len(m.Admin) @@ -887,11 +922,11 @@ func (m *MsgPlaceBid) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.AuctionTokenDenom) + l = len(m.AuctionName) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.AuctionTokenAmount.Size() + l = m.SellingTokenAmount.Size() n += 1 + l + sovTx(uint64(l)) l = m.PaymentTokenAmount.Size() n += 1 + l + sovTx(uint64(l)) @@ -917,10 +952,18 @@ func (m *MsgCreateAuction) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.AuctionName) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } if m.AuctionType != 0 { n += 1 + sovTx(uint64(m.AuctionType)) } - l = len(m.Denom) + l = len(m.SellingDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PaymentDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -957,13 +1000,13 @@ func (m *MsgUpdateAuction) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.AuctionType != 0 { - n += 1 + sovTx(uint64(m.AuctionType)) - } - l = len(m.Denom) + l = len(m.AuctionName) if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.AuctionType != 0 { + n += 1 + sovTx(uint64(m.AuctionType)) + } if m.Enabled { n += 2 } @@ -1056,7 +1099,7 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AuctionTokenDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AuctionName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1084,11 +1127,11 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AuctionTokenDenom = string(dAtA[iNdEx:postIndex]) + m.AuctionName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AuctionTokenAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SellingTokenAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1116,7 +1159,7 @@ func (m *MsgPlaceBid) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AuctionTokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.SellingTokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1287,6 +1330,38 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuctionName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AuctionType", wireType) } @@ -1305,9 +1380,9 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SellingDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1335,9 +1410,41 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.SellingDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PaymentDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PaymentDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } @@ -1357,7 +1464,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { } } m.Enabled = bool(v != 0) - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) } @@ -1391,7 +1498,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinBidAmount", wireType) } @@ -1425,7 +1532,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Beneficiary", wireType) } @@ -1590,27 +1697,8 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AuctionType", wireType) - } - m.AuctionType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AuctionType |= AuctionType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AuctionName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1638,8 +1726,27 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.AuctionName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionType", wireType) + } + m.AuctionType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionType |= AuctionType(b&0x7F) << shift + if b < 0x80 { + break + } + } case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) From a7e0836d6798bbff6ba928385553fc58fb9d0ad6 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 16:11:32 +0200 Subject: [PATCH 037/115] Standardizes API endpoints and fix auction queries - Update API endpoint patterns to consistently use /stride prefix - Change auction query param from 'denom' to 'name' for better semantics --- proto/stride/auction/query.proto | 6 +-- proto/stride/icqoracle/query.proto | 8 +-- x/auction/client/cli/query.go | 8 +-- x/auction/keeper/query.go | 2 +- x/auction/types/query.pb.go | 76 ++++++++++++++-------------- x/auction/types/query.pb.gw.go | 20 ++++---- x/icqoracle/types/query.pb.go | 80 +++++++++++++++--------------- x/icqoracle/types/query.pb.gw.go | 8 +-- 8 files changed, 104 insertions(+), 104 deletions(-) diff --git a/proto/stride/auction/query.proto b/proto/stride/auction/query.proto index 856737c7e0..7586a64cc7 100644 --- a/proto/stride/auction/query.proto +++ b/proto/stride/auction/query.proto @@ -12,18 +12,18 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/auction/types"; service Query { // Auction queries the auction info for a specific token rpc Auction(QueryAuctionRequest) returns (QueryAuctionResponse) { - option (google.api.http).get = "/auction/auction/{denom}"; + option (google.api.http).get = "/stride/auction/{name}"; } // Auctions queries the auction info for a specific token rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) { - option (google.api.http).get = "/auction/auctions"; + option (google.api.http).get = "/stride/auction/auctions"; } } // QueryAuctionRequest is the request type for the Query/Auction RPC // method -message QueryAuctionRequest { string denom = 1; } +message QueryAuctionRequest { string name = 1; } // QueryAuctionResponse is the response type for the Query/Auction RPC // method diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index ffaa219810..d4797039ee 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -12,23 +12,23 @@ option go_package = "github.com/Stride-Labs/stride/v24/x/icqoracle/types"; service Query { // TokenPrice queries the current price for a specific token rpc TokenPrice(QueryTokenPriceRequest) returns (QueryTokenPriceResponse) { - option (google.api.http).get = "/icqoracle/v1beta1/price"; + option (google.api.http).get = "/stride/icqoracle/price"; } // TokenPrices queries all token prices rpc TokenPrices(QueryTokenPricesRequest) returns (QueryTokenPricesResponse) { - option (google.api.http).get = "/icqoracle/v1beta1/prices"; + option (google.api.http).get = "/stride/icqoracle/prices"; } // Params queries the oracle parameters rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/icqoracle/v1beta1/params"; + option (google.api.http).get = "/stride/icqoracle/params"; } // TokenPriceForQuoteDenom queries the exchange rate between two tokens rpc TokenPriceForQuoteDenom(QueryTokenPriceForQuoteDenomRequest) returns (QueryTokenPriceForQuoteDenomResponse) { - option (google.api.http).get = "/icqoracle/v1beta1/quote_price"; + option (google.api.http).get = "/stride/icqoracle/quote_price"; } } diff --git a/x/auction/client/cli/query.go b/x/auction/client/cli/query.go index ee50c621ba..082dcf6013 100644 --- a/x/auction/client/cli/query.go +++ b/x/auction/client/cli/query.go @@ -31,8 +31,8 @@ func GetQueryCmd() *cobra.Command { func CmdQueryAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "auction [denom]", - Short: "Query the auction info for a specific token", + Use: "auction [name]", + Short: "Query the auction info for a specific auction", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -42,7 +42,7 @@ func CmdQueryAuction() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) req := &types.QueryAuctionRequest{ - Denom: args[0], + Name: args[0], } res, err := queryClient.Auction(context.Background(), req) if err != nil { @@ -57,7 +57,7 @@ func CmdQueryAuction() *cobra.Command { func CmdQueryAuctions() *cobra.Command { cmd := &cobra.Command{ Use: "auctions", - Short: "Query all auctions", + Short: "Get all auctions", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/x/auction/keeper/query.go b/x/auction/keeper/query.go index 6482971633..768a9ff694 100644 --- a/x/auction/keeper/query.go +++ b/x/auction/keeper/query.go @@ -21,7 +21,7 @@ func (k Keeper) Auction(goCtx context.Context, req *types.QueryAuctionRequest) ( ctx := sdk.UnwrapSDKContext(goCtx) - auction, err := k.GetAuction(ctx, req.Denom) + auction, err := k.GetAuction(ctx, req.Name) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index c6f6e33b0e..35dc30bbea 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -33,7 +33,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryAuctionRequest is the request type for the Query/Auction RPC // method type QueryAuctionRequest struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } func (m *QueryAuctionRequest) Reset() { *m = QueryAuctionRequest{} } @@ -69,9 +69,9 @@ func (m *QueryAuctionRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAuctionRequest proto.InternalMessageInfo -func (m *QueryAuctionRequest) GetDenom() string { +func (m *QueryAuctionRequest) GetName() string { if m != nil { - return m.Denom + return m.Name } return "" } @@ -232,34 +232,34 @@ func init() { func init() { proto.RegisterFile("stride/auction/query.proto", fileDescriptor_8113674a9412675c) } var fileDescriptor_8113674a9412675c = []byte{ - // 428 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x2e, 0x29, 0xca, - 0x4c, 0x49, 0xd5, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, - 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x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xf4, 0x02, 0x12, - 0xd3, 0x53, 0xa1, 0x7a, 0x83, 0x90, 0x74, 0x2a, 0xcd, 0x66, 0xe4, 0x12, 0x45, 0xb3, 0x00, 0xea, - 0x64, 0x4b, 0x2e, 0x0e, 0xa8, 0x23, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x09, 0xbb, 0x19, 0xae, 0x5c, - 0xc8, 0x1d, 0xc5, 0x71, 0x4c, 0x60, 0xc7, 0xa9, 0x13, 0x74, 0x1c, 0xc4, 0x5e, 0x64, 0xd7, 0x19, - 0x7d, 0x66, 0xe4, 0x62, 0x05, 0xbb, 0x4e, 0xa8, 0x8c, 0x8b, 0x1d, 0x6a, 0x9b, 0x90, 0x32, 0xba, - 0x33, 0xb0, 0x44, 0x8f, 0x94, 0x0a, 0x7e, 0x45, 0x10, 0xbb, 0x94, 0x14, 0x9a, 0x2e, 0x3f, 0x99, - 0xcc, 0x24, 0x25, 0x24, 0x81, 0x1e, 0xf7, 0xfa, 0xd5, 0xe0, 0xf8, 0xac, 0x15, 0x2a, 0xe2, 0xe2, - 0x80, 0x85, 0x8c, 0x10, 0x5e, 0x33, 0x61, 0x31, 0x23, 0xa5, 0x4a, 0x40, 0x15, 0xd4, 0x6a, 0x49, - 0xb0, 0xd5, 0xc2, 0x42, 0x82, 0xe8, 0x56, 0x17, 0x3b, 0x79, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, - 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, - 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x61, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, - 0x7e, 0x30, 0xd8, 0x16, 0x5d, 0x9f, 0xc4, 0xa4, 0x62, 0x7d, 0x68, 0x02, 0x2e, 0x33, 0x32, 0xd1, - 0xaf, 0x80, 0x9b, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0xc5, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xc5, 0xc2, 0xaf, 0xf1, 0x71, 0x03, 0x00, 0x00, + // 422 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x4f, 0x6b, 0xdb, 0x30, + 0x14, 0xb7, 0xb2, 0x6c, 0xc9, 0x34, 0xd8, 0x41, 0xcb, 0x36, 0x63, 0x86, 0x17, 0xbc, 0xff, 0x83, + 0x49, 0x24, 0x1b, 0x8c, 0x1d, 0x97, 0xc3, 0x76, 0x68, 0xa1, 0xad, 0x7b, 0xeb, 0xa1, 0x20, 0xa7, + 0xc2, 0x35, 0x34, 0x96, 0x13, 0xc9, 0xa1, 0xa1, 0xf4, 0xd2, 0x4f, 0x50, 0xe8, 0xb1, 0x5f, 0x28, + 0xc7, 0x40, 0x2f, 0x3d, 0x95, 0x92, 0xf4, 0x43, 0xf4, 0x58, 0x2c, 0xc9, 0x69, 0x6c, 0x42, 0x72, + 0xf2, 0xc3, 0xef, 0xf7, 0x4f, 0xef, 0x3d, 0xe8, 0x08, 0x39, 0x88, 0x0e, 0x18, 0xa1, 0x69, 0x57, + 0x46, 0x3c, 0x26, 0xfd, 0x94, 0x0d, 0x46, 0x38, 0x19, 0x70, 0xc9, 0xd1, 0x4b, 0xdd, 0xc3, 0xa6, + 0xe7, 0x7c, 0xef, 0x72, 0xd1, 0xe3, 0x82, 0x04, 0x54, 0x30, 0x0d, 0x24, 0xc3, 0x56, 0xc0, 0x24, + 0x6d, 0x91, 0x84, 0x86, 0x51, 0x4c, 0x33, 0x94, 0xe6, 0x3a, 0x8d, 0x90, 0x87, 0x5c, 0x95, 0x24, + 0xab, 0xcc, 0xdf, 0x77, 0x21, 0xe7, 0xe1, 0x11, 0x23, 0x34, 0x89, 0x08, 0x8d, 0x63, 0x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9f, 0xd6, 0xa0, 0x8c, 0x71, 0x53, 0x19, 0x3b, 0xc8, 0x26, 0xcb, 0x2f, + 0x4f, 0x74, 0x36, 0xc6, 0x53, 0x17, 0x4c, 0xa6, 0x2e, 0xb8, 0x9d, 0xba, 0xe0, 0x7c, 0xe6, 0x5a, + 0x93, 0x99, 0x6b, 0x5d, 0xcf, 0x5c, 0x6b, 0xaf, 0x15, 0x46, 0xf2, 0x30, 0x0d, 0x70, 0x97, 0xf7, + 0xc8, 0xae, 0x62, 0xff, 0xd8, 0xa4, 0x81, 0xc8, 0x95, 0x86, 0xed, 0x5f, 0xe4, 0x78, 0xae, 0x27, + 0x47, 0x09, 0x13, 0xc1, 0x33, 0x75, 0xc8, 0x3f, 0x1f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xad, 0x54, + 0x0c, 0x04, 0x74, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -402,10 +402,10 @@ func (m *QueryAuctionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0xa } @@ -546,7 +546,7 @@ func (m *QueryAuctionRequest) Size() (n int) { } var l int _ = l - l = len(m.Denom) + l = len(m.Name) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -633,7 +633,7 @@ func (m *QueryAuctionRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -661,7 +661,7 @@ func (m *QueryAuctionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/auction/types/query.pb.gw.go b/x/auction/types/query.pb.gw.go index 59bb1faabd..6ae3c71981 100644 --- a/x/auction/types/query.pb.gw.go +++ b/x/auction/types/query.pb.gw.go @@ -44,15 +44,15 @@ func request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, c _ = err ) - val, ok = pathParams["denom"] + val, ok = pathParams["name"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } - protoReq.Denom, err = runtime.String(val) + protoReq.Name, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } msg, err := client.Auction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -71,15 +71,15 @@ func local_request_Query_Auction_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["denom"] + val, ok = pathParams["name"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } - protoReq.Denom, err = runtime.String(val) + protoReq.Name, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } msg, err := server.Auction(ctx, &protoReq) @@ -260,9 +260,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 0, 1, 0, 4, 1, 5, 1}, []string{"auction", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"stride", "auction", "name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auction", "auctions"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Auctions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "auction", "auctions"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 9ba0f89524..f1628335b0 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -428,46 +428,46 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 624 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4d, 0x6f, 0x12, 0x41, - 0x18, 0xc7, 0xd9, 0xbe, 0x60, 0xfa, 0xe0, 0xc1, 0x8c, 0x8d, 0x5d, 0x57, 0x5c, 0x70, 0xad, 0x58, - 0x9b, 0x74, 0x27, 0xa5, 0xda, 0x0f, 0x80, 0x58, 0x63, 0x62, 0x13, 0x8a, 0x9e, 0x3c, 0x48, 0x86, - 0x65, 0xb2, 0x6e, 0x0a, 0x3b, 0xcb, 0xce, 0xd2, 0xb4, 0x57, 0x3d, 0x78, 0x35, 0xf1, 0x5b, 0x78, - 0xf2, 0x43, 0x78, 0xe8, 0xb1, 0x89, 0x17, 0xe3, 0xa1, 0x31, 0xe0, 0x07, 0x31, 0x3b, 0x33, 0xc0,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 0x2e, 0x7f, 0x5b, 0x81, - 0x55, 0xd1, 0x0e, 0x7d, 0xd0, 0x00, 0xc6, 0x3d, 0xd1, 0x56, 0x7a, 0x2b, 0xd3, 0x5f, 0x91, 0xf1, - 0x68, 0x81, 0x48, 0xc9, 0x6c, 0x15, 0xdf, 0x7f, 0xff, 0xfd, 0x79, 0xc9, 0x40, 0x7a, 0xe2, 0x73, - 0x30, 0x7a, 0xb7, 0xa2, 0xed, 0x47, 0x0d, 0x72, 0x09, 0xc5, 0xa1, 0xf9, 0xc5, 0x87, 0xd7, 0x6d, - 0x6c, 0x2f, 0x12, 0xaa, 0x40, 0xee, 0x09, 0x90, 0x3b, 0xe8, 0xf6, 0x2c, 0x10, 0x8e, 0x4e, 0x21, - 0x2b, 0x65, 0x80, 0x36, 0x67, 0x14, 0x9e, 0x50, 0x9b, 0xf1, 0x60, 0x4e, 0xd4, 0x22, 0x9d, 0x65, - 0xbf, 0xaf, 0x1a, 0x6c, 0xcc, 0xb8, 0x7d, 0xf4, 0x64, 0xee, 0x90, 0xd3, 0x44, 0x69, 0xec, 0xff, - 0x6b, 0x9a, 0xa2, 0x2d, 0x09, 0xda, 0x22, 0x32, 0xa7, 0xd0, 0x4a, 0x19, 0x8b, 0x6d, 0x55, 0x0e, - 0xcf, 0xfb, 0xa6, 0x76, 0xd1, 0x37, 0xb5, 0x5f, 0x7d, 0x53, 0xfb, 0x34, 0x30, 0x33, 0x17, 0x03, - 0x33, 0xf3, 0x63, 0x60, 0x66, 0xde, 0xec, 0x25, 0xf4, 0xf8, 0x4a, 0x30, 0xec, 0xbc, 0x24, 0x4d, - 0x8e, 0xd5, 0xcf, 0xc2, 0x49, 0xf9, 0x31, 0x3e, 0x4d, 0x14, 0x17, 0x02, 0x6d, 0x66, 0xc5, 0x97, - 0x7b, 0xef, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0xc9, 0x64, 0xa4, 0x6d, 0x06, 0x00, 0x00, + // 622 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0xfb, 0x13, 0xd4, 0x09, 0x07, 0xb4, 0x54, 0xc4, 0x58, 0xa9, 0x13, 0x99, 0xb6, 0x94, + 0x4a, 0xf5, 0xaa, 0x29, 0xf4, 0x01, 0x42, 0x28, 0x42, 0xa2, 0x52, 0x1a, 0x38, 0x71, 0x20, 0xda, + 0x38, 0x2b, 0x63, 0x35, 0xf1, 0x3a, 0x5e, 0xa7, 0xd0, 0x6b, 0x0f, 0x9c, 0x91, 0x78, 0x0b, 0x2e, + 0xbc, 0x02, 0xc7, 0x1e, 0x2b, 0x71, 0x41, 0x1c, 0x2a, 0x94, 0xf0, 0x20, 0xc8, 0xbb, 0xeb, 0xfc, + 0xd4, 0x09, 0x09, 0x12, 0xa7, 0x6c, 0x66, 0xbe, 0x99, 0xf9, 0xe6, 0xdb, 0xcf, 0x0b, 0x05, 0x1e, + 0x85, 0x5e, 0x8b, 0x62, 0xcf, 0xe9, 0xb2, 0x90, 0x38, 0x6d, 0x8a, 0xbb, 0x3d, 0x1a, 0x9e, 0xdb, + 0x41, 0xc8, 0x22, 0x86, 0xee, 0xc8, 0xac, 0x3d, 0xcc, 0x1a, 0xa5, 0x14, 0x7e, 0x78, 0x92, 0x35, + 0xc6, 0xba, 0xcb, 0x5c, 0x26, 0x8e, 0x38, 0x3e, 0xa9, 0x68, 0xc1, 0x65, 0xcc, 0x6d, 0x53, 0x4c, + 0x02, 0x0f, 0x13, 0xdf, 0x67, 0x11, 0x89, 0x3c, 0xe6, 0x73, 0x95, 0xdd, 0x75, 0x18, 0xef, 0x30, + 0x8e, 0x9b, 0x84, 0x2b, 0x02, 0xf8, 0x6c, 0xbf, 0x49, 0x23, 0xb2, 0x8f, 0x03, 0xe2, 0x7a, 0xbe, + 0x00, 0x4b, 0xac, 0xd5, 0x85, 0x7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8, 0x6e, 0x09, 0xb2, 0x45, 0xb4, 0x81, 0xa7, 0xbc, 0xf9, 0xb1, 0x85, 0x85, 0x56, 0x95, 0xe3, + 0xcb, 0xbe, 0xa9, 0x5d, 0xf5, 0x4d, 0xed, 0x57, 0xdf, 0xd4, 0x3e, 0x0d, 0xcc, 0xcc, 0xd5, 0xc0, + 0xcc, 0xfc, 0x18, 0x98, 0x99, 0x37, 0x07, 0x63, 0x5e, 0x7c, 0x25, 0x5a, 0xec, 0xbd, 0x24, 0x4d, + 0x9e, 0xb4, 0x3b, 0x2b, 0x3f, 0xc6, 0x1f, 0xc6, 0x9a, 0x0a, 0x73, 0x36, 0xb3, 0xe2, 0xd5, 0x3e, + 0xf8, 0x13, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xcb, 0x26, 0x10, 0x69, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/icqoracle/types/query.pb.gw.go b/x/icqoracle/types/query.pb.gw.go index 368423edc4..26446a8d16 100644 --- a/x/icqoracle/types/query.pb.gw.go +++ b/x/icqoracle/types/query.pb.gw.go @@ -382,13 +382,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "price"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "icqoracle", "price"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "prices"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "icqoracle", "prices"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "icqoracle", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TokenPriceForQuoteDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"icqoracle", "v1beta1", "quote_price"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TokenPriceForQuoteDenom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "icqoracle", "quote_price"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( From 97cccc7772373739ef39d274dd4484779d475a07 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 16:14:15 +0200 Subject: [PATCH 038/115] removes unused bank keeper functions --- x/auction/types/expected_keepers.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/x/auction/types/expected_keepers.go b/x/auction/types/expected_keepers.go index 2b3956545f..91e2160752 100644 --- a/x/auction/types/expected_keepers.go +++ b/x/auction/types/expected_keepers.go @@ -13,10 +13,7 @@ type AccountKeeper interface { // Required BankKeeper functions type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - GetSupply(ctx sdk.Context, denom string) sdk.Coin - MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } From b8c75cafa058f67ee73d0eead264069dc44fd6f2 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 16:23:13 +0200 Subject: [PATCH 039/115] Adds price mapping description in GetTokenPricesByDenom Co-authored-by: sampocs --- x/icqoracle/keeper/keeper.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 428e3a1773..859a097930 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -116,6 +116,7 @@ func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (typ } // GetTokenPriceByDenom retrieves all price data for a base denom +// Returned as a mapping of each quote denom to the spot price func (k Keeper) GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*types.TokenPrice, error) { store := ctx.KVStore(k.storeKey) From 49ec193cb1e23b0c7452db84224f530eed4d9c2c Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 16:26:40 +0200 Subject: [PATCH 040/115] update token price key format to use separator --- x/icqoracle/types/keys.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index debd630c48..a3fa62e5cc 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -11,15 +11,14 @@ const ( // RouterKey defines the routing key RouterKey = ModuleName - ParamsPrefix = "params" - KeyPricePrefix = "price" - KeyLastUpdateTime = "last_update_time" + ParamsPrefix = "params" + KeyPricePrefix = "price" ) func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { - return []byte(fmt.Sprintf("%s%s%s%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) + return []byte(fmt.Sprintf("%s|%s|%s|%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) } func TokenPriceByDenomKey(baseDenom string) []byte { - return []byte(fmt.Sprintf("%s%s", KeyPricePrefix, baseDenom)) + return []byte(fmt.Sprintf("%s|%s", KeyPricePrefix, baseDenom)) } From 6533e6fee8454490c5b8726cec9b3f9f4d66b256 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 16:30:31 +0200 Subject: [PATCH 041/115] remove unnecessary crap --- x/icqoracle/keeper/keeper.go | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 859a097930..95b3c21eb8 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -1,9 +1,7 @@ package keeper import ( - "encoding/binary" "fmt" - "time" "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" @@ -43,25 +41,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// SetLastUpdateTime stores the last time prices were updated -func (k Keeper) SetLastUpdateTime(ctx sdk.Context, timestamp time.Time) { - store := ctx.KVStore(k.storeKey) - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, uint64(ctx.BlockTime().UnixNano())) - store.Set([]byte(types.KeyLastUpdateTime), bz) -} - -// GetLastUpdateTime retrieves the last time prices were updated -func (k Keeper) GetLastUpdateTime(ctx sdk.Context) (time.Time, error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get([]byte(types.KeyLastUpdateTime)) - if bz == nil { - return time.Time{}, fmt.Errorf("last update time not found") - } - nanos := int64(binary.BigEndian.Uint64(bz)) - return time.Unix(0, nanos), nil -} - // SetTokenPrice stores price data for a token func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { store := ctx.KVStore(k.storeKey) From 96aea3f5ed867755fe40004efe84e1a376ff428c Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 16:35:44 +0200 Subject: [PATCH 042/115] wire auction in app.go --- app/app.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 292b434443..12e2c6abfc 100644 --- a/app/app.go +++ b/app/app.go @@ -129,6 +129,10 @@ import ( airdrop "github.com/Stride-Labs/stride/v24/x/airdrop" airdropkeeper "github.com/Stride-Labs/stride/v24/x/airdrop/keeper" airdroptypes "github.com/Stride-Labs/stride/v24/x/airdrop/types" + "github.com/Stride-Labs/stride/v24/x/auction" + auctionkeeper "github.com/Stride-Labs/stride/v24/x/auction/keeper" + auctiontypes "github.com/Stride-Labs/stride/v24/x/auction/types" + "github.com/Stride-Labs/stride/v24/x/autopilot" autopilotkeeper "github.com/Stride-Labs/stride/v24/x/autopilot/keeper" autopilottypes "github.com/Stride-Labs/stride/v24/x/autopilot/types" @@ -240,6 +244,7 @@ var ( ibcwasm.AppModuleBasic{}, airdrop.AppModuleBasic{}, icqoracle.AppModuleBasic{}, + auction.AppModuleBasic{}, ) // module account permissions @@ -353,6 +358,7 @@ type StrideApp struct { StakedymKeeper stakedymkeeper.Keeper AirdropKeeper airdropkeeper.Keeper ICQOracleKeeper icqoraclekeeper.Keeper + AuctionKeeper auctionkeeper.Keeper mm *module.Manager sm *module.SimulationManager @@ -410,6 +416,7 @@ func NewStrideApp( ibcwasmtypes.StoreKey, airdroptypes.StoreKey, icqoracletypes.StoreKey, + auctiontypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -763,7 +770,6 @@ func NewStrideApp( app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.StakingKeeper, ) - // ICQOracle Keeper must be initialized after TransferKeeper app.ICQOracleKeeper = *icqoraclekeeper.NewKeeper( appCodec, keys[icqoracletypes.StoreKey], @@ -772,6 +778,15 @@ func NewStrideApp( ) icqOracleModule := icqoracle.NewAppModule(appCodec, app.ICQOracleKeeper) + app.AuctionKeeper = *auctionkeeper.NewKeeper( + appCodec, + keys[auctiontypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + app.ICQOracleKeeper, + ) + auctionModule := auction.NewAppModule(appCodec, app.AuctionKeeper) + // Register Gov (must be registered after stakeibc) govRouter := govtypesv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). @@ -950,6 +965,7 @@ func NewStrideApp( airdropModule, stakeTiaModule, icqOracleModule, + auctionModule, ) // During begin block slashing happens after distr.BeginBlocker so that @@ -996,6 +1012,7 @@ func NewStrideApp( ibcwasmtypes.ModuleName, airdroptypes.ModuleName, icqoracletypes.ModuleName, + auctiontypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -1038,6 +1055,7 @@ func NewStrideApp( ibcwasmtypes.ModuleName, airdroptypes.ModuleName, icqoracletypes.ModuleName, + auctiontypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -1085,6 +1103,7 @@ func NewStrideApp( ibcwasmtypes.ModuleName, airdroptypes.ModuleName, icqoracletypes.ModuleName, + auctiontypes.ModuleName, ) app.mm.RegisterInvariants(app.CrisisKeeper) From 02cd50b5cb1ef18f4665ff064a16b7737d323035 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 17:20:49 +0200 Subject: [PATCH 043/115] x/strdburner proto --- proto/stride/strdburner/query.proto | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 proto/stride/strdburner/query.proto diff --git a/proto/stride/strdburner/query.proto b/proto/stride/strdburner/query.proto new file mode 100644 index 0000000000..9adac0daaf --- /dev/null +++ b/proto/stride/strdburner/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package stride.strdburner; + +import "cosmos_proto/cosmos.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/Stride-Labs/stride/v24/x/strdburner/types"; + +// Query defines the gRPC querier service. +service Query { + // StrdBurnerAddress queries the address of the strdburner module + rpc StrdBurnerAddress(QueryStrdBurnerAddressRequest) + returns (QueryStrdBurnerAddressResponse) { + option (google.api.http).get = "/stride/strdburner/address"; + } +} + +// QueryStrdBurnerAddressRequest is the request type for the Query/strdburner +// RPC method +message QueryStrdBurnerAddressRequest { string name = 1; } + +// QueryStrdBurnerAddressResponse is the response type for the Query/strdburner +// RPC method +message QueryStrdBurnerAddressResponse { + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} From eaf8d76830b36f11d7437228819503a37bc0092b Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 17:48:28 +0200 Subject: [PATCH 044/115] x/strdburner initial impl --- proto/stride/strdburner/genesis.proto | 7 + proto/stride/strdburner/query.proto | 2 +- x/strdburner/client/cli/query.go | 51 +++ x/strdburner/keeper/abci.go | 20 + x/strdburner/keeper/genesis.go | 16 + x/strdburner/keeper/keeper.go | 42 ++ x/strdburner/keeper/query.go | 16 + x/strdburner/module.go | 155 +++++++ x/strdburner/types/codec.go | 30 ++ x/strdburner/types/expected_keepers.go | 16 + x/strdburner/types/genesis.go | 12 + x/strdburner/types/genesis.pb.go | 264 ++++++++++++ x/strdburner/types/keys.go | 11 + x/strdburner/types/query.pb.go | 535 +++++++++++++++++++++++++ x/strdburner/types/query.pb.gw.go | 153 +++++++ 15 files changed, 1329 insertions(+), 1 deletion(-) create mode 100644 proto/stride/strdburner/genesis.proto create mode 100644 x/strdburner/client/cli/query.go create mode 100644 x/strdburner/keeper/abci.go create mode 100644 x/strdburner/keeper/genesis.go create mode 100644 x/strdburner/keeper/keeper.go create mode 100644 x/strdburner/keeper/query.go create mode 100644 x/strdburner/module.go create mode 100644 x/strdburner/types/codec.go create mode 100644 x/strdburner/types/expected_keepers.go create mode 100644 x/strdburner/types/genesis.go create mode 100644 x/strdburner/types/genesis.pb.go create mode 100644 x/strdburner/types/keys.go create mode 100644 x/strdburner/types/query.pb.go create mode 100644 x/strdburner/types/query.pb.gw.go diff --git a/proto/stride/strdburner/genesis.proto b/proto/stride/strdburner/genesis.proto new file mode 100644 index 0000000000..711729409a --- /dev/null +++ b/proto/stride/strdburner/genesis.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package stride.strdburner; + +option go_package = "github.com/Stride-Labs/stride/v24/x/strdburner/types"; + +// GenesisState defines the strdburner module's genesis state +message GenesisState {} \ No newline at end of file diff --git a/proto/stride/strdburner/query.proto b/proto/stride/strdburner/query.proto index 9adac0daaf..17d95d38b3 100644 --- a/proto/stride/strdburner/query.proto +++ b/proto/stride/strdburner/query.proto @@ -17,7 +17,7 @@ service Query { // QueryStrdBurnerAddressRequest is the request type for the Query/strdburner // RPC method -message QueryStrdBurnerAddressRequest { string name = 1; } +message QueryStrdBurnerAddressRequest {} // QueryStrdBurnerAddressResponse is the response type for the Query/strdburner // RPC method diff --git a/x/strdburner/client/cli/query.go b/x/strdburner/client/cli/query.go new file mode 100644 index 0000000000..81c5475540 --- /dev/null +++ b/x/strdburner/client/cli/query.go @@ -0,0 +1,51 @@ +package cli + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdQueryStrdBurnerAddress(), + ) + + return cmd +} + +func CmdQueryStrdBurnerAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "address", + Short: "Query the address of the stride burner module", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryStrdBurnerAddressRequest{} + res, err := queryClient.StrdBurnerAddress(context.Background(), req) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} diff --git a/x/strdburner/keeper/abci.go b/x/strdburner/keeper/abci.go new file mode 100644 index 0000000000..e1abfc5211 --- /dev/null +++ b/x/strdburner/keeper/abci.go @@ -0,0 +1,20 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +func EndBlocker(ctx sdk.Context, k Keeper) { + strdBurnerAddress := k.GetStrdBurnerAddress() + + strdBalance := k.bankKeeper.GetBalance(ctx, strdBurnerAddress, "ustrd") + + if strdBalance.IsPositive() { + err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(strdBalance)) + if err != nil { + k.Logger(ctx).Error("unable to burn %s", strdBalance.String()) + } + } +} diff --git a/x/strdburner/keeper/genesis.go b/x/strdburner/keeper/genesis.go new file mode 100644 index 0000000000..632526cfa6 --- /dev/null +++ b/x/strdburner/keeper/genesis.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +// Loads module state from genesis +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { +} + +// Export's module state into genesis file +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return types.DefaultGenesis() +} diff --git a/x/strdburner/keeper/keeper.go b/x/strdburner/keeper/keeper.go new file mode 100644 index 0000000000..4f4f79651e --- /dev/null +++ b/x/strdburner/keeper/keeper.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) GetStrdBurnerAddress() sdk.AccAddress { + return k.accountKeeper.GetModuleAddress(types.ModuleName) +} diff --git a/x/strdburner/keeper/query.go b/x/strdburner/keeper/query.go new file mode 100644 index 0000000000..0f74d0809b --- /dev/null +++ b/x/strdburner/keeper/query.go @@ -0,0 +1,16 @@ +package keeper + +import ( + "context" + + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +var _ types.QueryServer = Keeper{} + +// Auction queries the auction info for a specific token +func (k Keeper) StrdBurnerAddress(goCtx context.Context, req *types.QueryStrdBurnerAddressRequest) (*types.QueryStrdBurnerAddressResponse, error) { + return &types.QueryStrdBurnerAddressResponse{ + Address: k.GetStrdBurnerAddress().String(), + }, nil +} diff --git a/x/strdburner/module.go b/x/strdburner/module.go new file mode 100644 index 0000000000..ac84331660 --- /dev/null +++ b/x/strdburner/module.go @@ -0,0 +1,155 @@ +package strdburner + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Stride-Labs/stride/v24/x/strdburner/client/cli" + "github.com/Stride-Labs/stride/v24/x/strdburner/keeper" + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + am.keeper.InitGenesis(ctx, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/strdburner/types/codec.go b/x/strdburner/types/codec.go new file mode 100644 index 0000000000..f19b5671fb --- /dev/null +++ b/x/strdburner/types/codec.go @@ -0,0 +1,30 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" +) + +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be + // used to properly serialize MsgSubmitProposal instances + RegisterLegacyAminoCodec(govcodec.Amino) +} diff --git a/x/strdburner/types/expected_keepers.go b/x/strdburner/types/expected_keepers.go new file mode 100644 index 0000000000..b6ef118391 --- /dev/null +++ b/x/strdburner/types/expected_keepers.go @@ -0,0 +1,16 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Required AccountKeeper functions +type AccountKeeper interface { + GetModuleAddress(moduleName string) sdk.AccAddress +} + +// Required BankKeeper functions +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error +} diff --git a/x/strdburner/types/genesis.go b/x/strdburner/types/genesis.go new file mode 100644 index 0000000000..58672eec72 --- /dev/null +++ b/x/strdburner/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Performs basic genesis state validation by iterating through all auctions and validating +// using ValidateBasic() since it already implements thorough validation of all auction fields +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/strdburner/types/genesis.pb.go b/x/strdburner/types/genesis.pb.go new file mode 100644 index 0000000000..7e51493c15 --- /dev/null +++ b/x/strdburner/types/genesis.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/strdburner/genesis.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the strdburner module's genesis state +type GenesisState struct { +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_003ecc60d66895bb, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "stride.strdburner.GenesisState") +} + +func init() { proto.RegisterFile("stride/strdburner/genesis.proto", fileDescriptor_003ecc60d66895bb) } + +var fileDescriptor_003ecc60d66895bb = []byte{ + // 145 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x2e, 0x29, 0xca, + 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x29, 0x4a, 0x49, 0x2a, 0x2d, 0xca, 0x4b, 0x2d, 0xd2, 0x4f, 0x4f, + 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x28, 0xd0, + 0x43, 0x28, 0x50, 0xe2, 0xe3, 0xe2, 0x71, 0x87, 0xa8, 0x09, 0x2e, 0x49, 0x2c, 0x49, 0x75, 0xf2, + 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, + 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, 0x92, 0x8c, + 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0x60, 0xb0, 0x39, 0xba, 0x3e, 0x89, 0x49, 0xc5, 0xfa, + 0x50, 0x4b, 0xcb, 0x8c, 0x4c, 0xf4, 0x2b, 0x90, 0xad, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, + 0x03, 0xdb, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x1d, 0x54, 0xa0, 0x4f, 0x9c, 0x00, 0x00, + 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/strdburner/types/keys.go b/x/strdburner/types/keys.go new file mode 100644 index 0000000000..d5d14edc12 --- /dev/null +++ b/x/strdburner/types/keys.go @@ -0,0 +1,11 @@ +package types + +const ( + ModuleName = "strdburner" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the routing key + RouterKey = ModuleName +) diff --git a/x/strdburner/types/query.pb.go b/x/strdburner/types/query.pb.go new file mode 100644 index 0000000000..a70dd39843 --- /dev/null +++ b/x/strdburner/types/query.pb.go @@ -0,0 +1,535 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: stride/strdburner/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryStrdBurnerAddressRequest is the request type for the Query/strdburner +// RPC method +type QueryStrdBurnerAddressRequest struct { +} + +func (m *QueryStrdBurnerAddressRequest) Reset() { *m = QueryStrdBurnerAddressRequest{} } +func (m *QueryStrdBurnerAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStrdBurnerAddressRequest) ProtoMessage() {} +func (*QueryStrdBurnerAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_76c45869caa19016, []int{0} +} +func (m *QueryStrdBurnerAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStrdBurnerAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStrdBurnerAddressRequest.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 *QueryStrdBurnerAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStrdBurnerAddressRequest.Merge(m, src) +} +func (m *QueryStrdBurnerAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStrdBurnerAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStrdBurnerAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStrdBurnerAddressRequest proto.InternalMessageInfo + +// QueryStrdBurnerAddressResponse is the response type for the Query/strdburner +// RPC method +type QueryStrdBurnerAddressResponse struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryStrdBurnerAddressResponse) Reset() { *m = QueryStrdBurnerAddressResponse{} } +func (m *QueryStrdBurnerAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStrdBurnerAddressResponse) ProtoMessage() {} +func (*QueryStrdBurnerAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76c45869caa19016, []int{1} +} +func (m *QueryStrdBurnerAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStrdBurnerAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStrdBurnerAddressResponse.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 *QueryStrdBurnerAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStrdBurnerAddressResponse.Merge(m, src) +} +func (m *QueryStrdBurnerAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStrdBurnerAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStrdBurnerAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStrdBurnerAddressResponse proto.InternalMessageInfo + +func (m *QueryStrdBurnerAddressResponse) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func init() { + proto.RegisterType((*QueryStrdBurnerAddressRequest)(nil), "stride.strdburner.QueryStrdBurnerAddressRequest") + proto.RegisterType((*QueryStrdBurnerAddressResponse)(nil), "stride.strdburner.QueryStrdBurnerAddressResponse") +} + +func init() { proto.RegisterFile("stride/strdburner/query.proto", fileDescriptor_76c45869caa19016) } + +var fileDescriptor_76c45869caa19016 = []byte{ + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x2e, 0x29, 0xca, + 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x29, 0x4a, 0x49, 0x2a, 0x2d,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, 0xbf, 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, 0x32, 0x49, 0xcf, 0x2c, + 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x06, 0xeb, 0xd7, 0xf5, 0x49, 0x4c, 0x2a, + 0x86, 0x99, 0x55, 0x66, 0x64, 0xa2, 0x5f, 0x81, 0x6c, 0x62, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0x38, 0xd8, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x61, 0xab, 0xc8, 0x33, 0xe3, 0x01, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // StrdBurnerAddress queries the address of the strdburner module + StrdBurnerAddress(ctx context.Context, in *QueryStrdBurnerAddressRequest, opts ...grpc.CallOption) (*QueryStrdBurnerAddressResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) StrdBurnerAddress(ctx context.Context, in *QueryStrdBurnerAddressRequest, opts ...grpc.CallOption) (*QueryStrdBurnerAddressResponse, error) { + out := new(QueryStrdBurnerAddressResponse) + err := c.cc.Invoke(ctx, "/stride.strdburner.Query/StrdBurnerAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // StrdBurnerAddress queries the address of the strdburner module + StrdBurnerAddress(context.Context, *QueryStrdBurnerAddressRequest) (*QueryStrdBurnerAddressResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) StrdBurnerAddress(ctx context.Context, req *QueryStrdBurnerAddressRequest) (*QueryStrdBurnerAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StrdBurnerAddress not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_StrdBurnerAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStrdBurnerAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StrdBurnerAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.strdburner.Query/StrdBurnerAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StrdBurnerAddress(ctx, req.(*QueryStrdBurnerAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "stride.strdburner.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "StrdBurnerAddress", + Handler: _Query_StrdBurnerAddress_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "stride/strdburner/query.proto", +} + +func (m *QueryStrdBurnerAddressRequest) 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 *QueryStrdBurnerAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStrdBurnerAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryStrdBurnerAddressResponse) 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 *QueryStrdBurnerAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStrdBurnerAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryStrdBurnerAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryStrdBurnerAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryStrdBurnerAddressRequest) 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: QueryStrdBurnerAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStrdBurnerAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryStrdBurnerAddressResponse) 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: QueryStrdBurnerAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStrdBurnerAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/strdburner/types/query.pb.gw.go b/x/strdburner/types/query.pb.gw.go new file mode 100644 index 0000000000..dc1143236c --- /dev/null +++ b/x/strdburner/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: stride/strdburner/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_StrdBurnerAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStrdBurnerAddressRequest + var metadata runtime.ServerMetadata + + msg, err := client.StrdBurnerAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StrdBurnerAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStrdBurnerAddressRequest + var metadata runtime.ServerMetadata + + msg, err := server.StrdBurnerAddress(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_StrdBurnerAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_StrdBurnerAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_StrdBurnerAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_StrdBurnerAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_StrdBurnerAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_StrdBurnerAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_StrdBurnerAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "strdburner", "address"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_StrdBurnerAddress_0 = runtime.ForwardResponseMessage +) From 9ec3eb1d0136ac7e6cd3e7b91a9dc5b37d107405 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 20:32:58 +0200 Subject: [PATCH 045/115] add burn event --- x/strdburner/keeper/abci.go | 7 +++++++ x/strdburner/types/events.go | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 x/strdburner/types/events.go diff --git a/x/strdburner/keeper/abci.go b/x/strdburner/keeper/abci.go index e1abfc5211..44544f4c2d 100644 --- a/x/strdburner/keeper/abci.go +++ b/x/strdburner/keeper/abci.go @@ -15,6 +15,13 @@ func EndBlocker(ctx sdk.Context, k Keeper) { err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(strdBalance)) if err != nil { k.Logger(ctx).Error("unable to burn %s", strdBalance.String()) + } else { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeBurn, + sdk.NewAttribute(types.AttributeAmount, strdBalance.String()), + ), + ) } } } diff --git a/x/strdburner/types/events.go b/x/strdburner/types/events.go new file mode 100644 index 0000000000..bd53b10940 --- /dev/null +++ b/x/strdburner/types/events.go @@ -0,0 +1,8 @@ +package types + +// strdburner module event typs +const ( + EventTypeBurn = "burn" + + AttributeAmount = "amount" +) From 7a539dc2669460b51c393d4b2aef818c6153abff Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 20:34:09 +0200 Subject: [PATCH 046/115] strdburner: improve error logging in endblocker --- x/strdburner/keeper/abci.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/strdburner/keeper/abci.go b/x/strdburner/keeper/abci.go index 44544f4c2d..0fc7206f2f 100644 --- a/x/strdburner/keeper/abci.go +++ b/x/strdburner/keeper/abci.go @@ -14,7 +14,7 @@ func EndBlocker(ctx sdk.Context, k Keeper) { if strdBalance.IsPositive() { err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(strdBalance)) if err != nil { - k.Logger(ctx).Error("unable to burn %s", strdBalance.String()) + k.Logger(ctx).Error("unable to burn %s: %w", strdBalance.String(), err) } else { ctx.EventManager().EmitEvent( sdk.NewEvent( From 241f69c8455d09cdeb7fc251c3080ca12501b937 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 20:34:21 +0200 Subject: [PATCH 047/115] fix code comment --- x/auction/keeper/auction_type.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index b7f22d5113..d81b9dbd24 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -74,7 +74,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type ) } - // Send auctionToken to bidder + // Send sellingToken to bidder err = k.bankKeeper.SendCoinsFromModuleToAccount( ctx, types.ModuleName, From 3976b2df6847929bdac195cb2487c48190060656 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 21:00:43 +0200 Subject: [PATCH 048/115] implement TotalStrdBurned and refactor EndBlocker for readability --- proto/stride/strdburner/genesis.proto | 10 +- proto/stride/strdburner/query.proto | 20 ++ x/strdburner/keeper/abci.go | 36 ++- x/strdburner/keeper/genesis.go | 5 +- x/strdburner/keeper/keeper.go | 17 ++ x/strdburner/keeper/query.go | 8 + x/strdburner/types/genesis.go | 19 +- x/strdburner/types/genesis.pb.go | 70 ++++- x/strdburner/types/keys.go | 2 + x/strdburner/types/query.pb.go | 366 ++++++++++++++++++++++++-- x/strdburner/types/query.pb.gw.go | 65 +++++ 11 files changed, 577 insertions(+), 41 deletions(-) diff --git a/proto/stride/strdburner/genesis.proto b/proto/stride/strdburner/genesis.proto index 711729409a..7c7248a59b 100644 --- a/proto/stride/strdburner/genesis.proto +++ b/proto/stride/strdburner/genesis.proto @@ -1,7 +1,15 @@ syntax = "proto3"; package stride.strdburner; +import "gogoproto/gogo.proto"; + option go_package = "github.com/Stride-Labs/stride/v24/x/strdburner/types"; // GenesisState defines the strdburner module's genesis state -message GenesisState {} \ No newline at end of file +message GenesisState { + // Total amount of ustrd burned + string total_ustrd_burned = 9 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/stride/strdburner/query.proto b/proto/stride/strdburner/query.proto index 17d95d38b3..65acb4ba58 100644 --- a/proto/stride/strdburner/query.proto +++ b/proto/stride/strdburner/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package stride.strdburner; import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; option go_package = "github.com/Stride-Labs/stride/v24/x/strdburner/types"; @@ -13,6 +14,12 @@ service Query { returns (QueryStrdBurnerAddressResponse) { option (google.api.http).get = "/stride/strdburner/address"; } + + // StrdBurnerAddress queries the address of the strdburner module + rpc TotalStrdBurned(QueryTotalStrdBurnedRequest) + returns (QueryTotalStrdBurnedResponse) { + option (google.api.http).get = "/stride/strdburner/total_burned"; + } } // QueryStrdBurnerAddressRequest is the request type for the Query/strdburner @@ -24,3 +31,16 @@ message QueryStrdBurnerAddressRequest {} message QueryStrdBurnerAddressResponse { string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } + +// QueryTotalStrdBurnedRequest is the request type for the Query/strdburner +// RPC method +message QueryTotalStrdBurnedRequest {} + +// QueryTotalStrdBurnedResponse is the response type for the Query/strdburner +// RPC method +message QueryTotalStrdBurnedResponse { + string total_burned = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/x/strdburner/keeper/abci.go b/x/strdburner/keeper/abci.go index 0fc7206f2f..a9b08e313d 100644 --- a/x/strdburner/keeper/abci.go +++ b/x/strdburner/keeper/abci.go @@ -9,19 +9,31 @@ import ( func EndBlocker(ctx sdk.Context, k Keeper) { strdBurnerAddress := k.GetStrdBurnerAddress() + // Get STRD balance strdBalance := k.bankKeeper.GetBalance(ctx, strdBurnerAddress, "ustrd") - if strdBalance.IsPositive() { - err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(strdBalance)) - if err != nil { - k.Logger(ctx).Error("unable to burn %s: %w", strdBalance.String(), err) - } else { - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeBurn, - sdk.NewAttribute(types.AttributeAmount, strdBalance.String()), - ), - ) - } + // Exit early if nothing to burn + if strdBalance.IsZero() { + return } + + // Burn all STRD balance + err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(strdBalance)) + if err != nil { + k.Logger(ctx).Error("unable to burn %s: %w", strdBalance.String(), err) + return + } + + // Update TotalStrdBurned + currentTotalBurned := k.GetTotalStrdBurned(ctx) + newTotalBurned := currentTotalBurned.Add(strdBalance.Amount) + k.SetTotalStrdBurned(ctx, newTotalBurned) + + // Emit burn event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeBurn, + sdk.NewAttribute(types.AttributeAmount, strdBalance.String()), + ), + ) } diff --git a/x/strdburner/keeper/genesis.go b/x/strdburner/keeper/genesis.go index 632526cfa6..e2bdbe61c4 100644 --- a/x/strdburner/keeper/genesis.go +++ b/x/strdburner/keeper/genesis.go @@ -8,9 +8,12 @@ import ( // Loads module state from genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + k.SetTotalStrdBurned(ctx, genState.TotalUstrdBurned) } // Export's module state into genesis file func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - return types.DefaultGenesis() + genesis := types.DefaultGenesis() + genesis.TotalUstrdBurned = k.GetTotalStrdBurned(ctx) + return genesis } diff --git a/x/strdburner/keeper/keeper.go b/x/strdburner/keeper/keeper.go index 4f4f79651e..52463f6225 100644 --- a/x/strdburner/keeper/keeper.go +++ b/x/strdburner/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -40,3 +41,19 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) GetStrdBurnerAddress() sdk.AccAddress { return k.accountKeeper.GetModuleAddress(types.ModuleName) } + +func (k Keeper) SetTotalStrdBurned(ctx sdk.Context, amount math.Int) { + bz := sdk.Uint64ToBigEndian(amount.Uint64()) + ctx.KVStore(k.storeKey).Set([]byte(types.TotalStrdBurnedKey), bz) +} + +func (k Keeper) GetTotalStrdBurned(ctx sdk.Context) math.Int { + bz := ctx.KVStore(k.storeKey).Get([]byte(types.TotalStrdBurnedKey)) + + // If no value has been set, return zero + if bz == nil { + return math.ZeroInt() + } + + return math.NewIntFromUint64(sdk.BigEndianToUint64(bz)) +} diff --git a/x/strdburner/keeper/query.go b/x/strdburner/keeper/query.go index 0f74d0809b..0144e9363e 100644 --- a/x/strdburner/keeper/query.go +++ b/x/strdburner/keeper/query.go @@ -3,6 +3,8 @@ package keeper import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/Stride-Labs/stride/v24/x/strdburner/types" ) @@ -14,3 +16,9 @@ func (k Keeper) StrdBurnerAddress(goCtx context.Context, req *types.QueryStrdBur Address: k.GetStrdBurnerAddress().String(), }, nil } + +func (k Keeper) TotalStrdBurned(goCtx context.Context, req *types.QueryTotalStrdBurnedRequest) (*types.QueryTotalStrdBurnedResponse, error) { + return &types.QueryTotalStrdBurnedResponse{ + TotalBurned: k.GetTotalStrdBurned(sdk.UnwrapSDKContext(goCtx)), + }, nil +} diff --git a/x/strdburner/types/genesis.go b/x/strdburner/types/genesis.go index 58672eec72..aa88885642 100644 --- a/x/strdburner/types/genesis.go +++ b/x/strdburner/types/genesis.go @@ -1,12 +1,23 @@ package types +import ( + "fmt" + + "cosmossdk.io/math" +) + // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + TotalUstrdBurned: math.ZeroInt(), + } } -// Performs basic genesis state validation by iterating through all auctions and validating -// using ValidateBasic() since it already implements thorough validation of all auction fields +// Performs basic genesis state validation by func (gs GenesisState) Validate() error { - return nil + if gs.TotalUstrdBurned.IsNil() { + return fmt.Errorf("GenesisState.TotalUstrdBurned cannot be nil") + } else { + return nil + } } diff --git a/x/strdburner/types/genesis.pb.go b/x/strdburner/types/genesis.pb.go index 7e51493c15..dd7693f273 100644 --- a/x/strdburner/types/genesis.pb.go +++ b/x/strdburner/types/genesis.pb.go @@ -4,7 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -24,6 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the strdburner module's genesis state type GenesisState struct { + // Total amount of ustrd burned + TotalUstrdBurned cosmossdk_io_math.Int `protobuf:"bytes,9,opt,name=total_ustrd_burned,json=totalUstrdBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_ustrd_burned"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -66,17 +70,21 @@ func init() { func init() { proto.RegisterFile("stride/strdburner/genesis.proto", fileDescriptor_003ecc60d66895bb) } var fileDescriptor_003ecc60d66895bb = []byte{ - // 145 bytes of a gzipped FileDescriptorProto + // 223 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x2e, 0x29, 0xca, 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x29, 0x4a, 0x49, 0x2a, 0x2d, 0xca, 0x4b, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x28, 0xd0, - 0x43, 0x28, 0x50, 0xe2, 0xe3, 0xe2, 0x71, 0x87, 0xa8, 0x09, 0x2e, 0x49, 0x2c, 0x49, 0x75, 0xf2, - 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, - 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0x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, 0xfa, 0xc1, 0x60, 0xa7, 0xea, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0xfd, 0x55, + 0x66, 0x64, 0xa2, 0x5f, 0x81, 0xec, 0xbb, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x9b, + 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x11, 0x3a, 0xa0, 0xff, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -99,6 +107,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TotalUstrdBurned.Size() + i -= size + if _, err := m.TotalUstrdBurned.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a return len(dAtA) - i, nil } @@ -119,6 +137,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.TotalUstrdBurned.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -157,6 +177,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalUstrdBurned", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalUstrdBurned.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/strdburner/types/keys.go b/x/strdburner/types/keys.go index d5d14edc12..269cc15aef 100644 --- a/x/strdburner/types/keys.go +++ b/x/strdburner/types/keys.go @@ -8,4 +8,6 @@ const ( // RouterKey defines the routing key RouterKey = ModuleName + + TotalStrdBurnedKey = "total_burned" ) diff --git a/x/strdburner/types/query.pb.go b/x/strdburner/types/query.pb.go index a70dd39843..43b0c31a11 100644 --- a/x/strdburner/types/query.pb.go +++ b/x/strdburner/types/query.pb.go @@ -5,8 +5,10 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -113,33 +115,119 @@ func (m *QueryStrdBurnerAddressResponse) GetAddress() string { return "" } +// QueryTotalStrdBurnedRequest is the request type for the Query/strdburner +// RPC method +type QueryTotalStrdBurnedRequest struct { +} + +func (m *QueryTotalStrdBurnedRequest) Reset() { *m = QueryTotalStrdBurnedRequest{} } +func (m *QueryTotalStrdBurnedRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalStrdBurnedRequest) ProtoMessage() {} +func (*QueryTotalStrdBurnedRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_76c45869caa19016, []int{2} +} +func (m *QueryTotalStrdBurnedRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalStrdBurnedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalStrdBurnedRequest.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 *QueryTotalStrdBurnedRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalStrdBurnedRequest.Merge(m, src) +} +func (m *QueryTotalStrdBurnedRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalStrdBurnedRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalStrdBurnedRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalStrdBurnedRequest proto.InternalMessageInfo + +// QueryTotalStrdBurnedResponse is the response type for the Query/strdburner +// RPC method +type QueryTotalStrdBurnedResponse struct { + TotalBurned cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total_burned,json=totalBurned,proto3,customtype=cosmossdk.io/math.Int" json:"total_burned"` +} + +func (m *QueryTotalStrdBurnedResponse) Reset() { *m = QueryTotalStrdBurnedResponse{} } +func (m *QueryTotalStrdBurnedResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalStrdBurnedResponse) ProtoMessage() {} +func (*QueryTotalStrdBurnedResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_76c45869caa19016, []int{3} +} +func (m *QueryTotalStrdBurnedResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalStrdBurnedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalStrdBurnedResponse.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 *QueryTotalStrdBurnedResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalStrdBurnedResponse.Merge(m, src) +} +func (m *QueryTotalStrdBurnedResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalStrdBurnedResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalStrdBurnedResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalStrdBurnedResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryStrdBurnerAddressRequest)(nil), "stride.strdburner.QueryStrdBurnerAddressRequest") proto.RegisterType((*QueryStrdBurnerAddressResponse)(nil), "stride.strdburner.QueryStrdBurnerAddressResponse") + proto.RegisterType((*QueryTotalStrdBurnedRequest)(nil), "stride.strdburner.QueryTotalStrdBurnedRequest") + proto.RegisterType((*QueryTotalStrdBurnedResponse)(nil), "stride.strdburner.QueryTotalStrdBurnedResponse") } func init() { proto.RegisterFile("stride/strdburner/query.proto", fileDescriptor_76c45869caa19016) } var fileDescriptor_76c45869caa19016 = []byte{ - // 290 bytes of a gzipped FileDescriptorProto + // 402 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x2e, 0x29, 0xca, 0x4c, 0x49, 0xd5, 0x2f, 0x2e, 0x29, 0x4a, 0x49, 0x2a, 0x2d, 0xca, 0x4b, 0x2d, 0xd2, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x48, 0xeb, 0x21, 0xa4, 0xa5, 0x24, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xe3, 0xc1, 0x0a, 0xf4, 0x21, 0x1c, 0x88, 0x6a, - 0x29, 0x99, 0xf4, 0xfc, 0xfc, 0xf4, 0x9c, 0x54, 0xfd, 0xc4, 0x82, 0x4c, 0xfd, 0xc4, 0xbc, 0xbc, - 0xfc, 0x92, 0xc4, 0x92, 0xcc, 0xfc, 0x3c, 0xa8, 0xac, 0x92, 0x3c, 0x97, 0x6c, 0x20, 0xc8, 0xe8, - 0xe0, 0x92, 0xa2, 0x14, 0x27, 0xb0, 0x59, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0x41, 0xa9, - 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0x21, 0x5c, 0x72, 0xb8, 0x14, 0x14, 0x17, 0xe4, 0xe7, 0x15, - 0xa7, 0x0a, 0x19, 0x71, 0xb1, 0x27, 0x42, 0x84, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x24, - 0x2e, 0x6d, 0xd1, 0x15, 0x81, 0xba, 0x01, 0xaa, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x08, - 0xa6, 0xd0, 0x68, 0x19, 0x23, 0x17, 0x2b, 0xd8, 0x58, 0xa1, 0x39, 0x8c, 0x5c, 0x82, 0x18, 0x66, - 0x0b, 0x19, 0xe8, 0x61, 0xf8, 0x51, 0x0f, 0xaf, 0x3b, 0xa5, 0x0c, 0x49, 0xd0, 0x01, 0x71, 0xb8, - 0x92, 0x52, 0xd3, 0xe5, 0x27, 0x93, 0x99, 0x64, 0x84, 0xa4, 0xf4, 0x31, 0xc3, 0x1b, 0xea, 0x50, - 0x27, 0xbf, 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, 0x32, 0x49, 0xcf, 0x2c, - 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x06, 0xeb, 0xd7, 0xf5, 0x49, 0x4c, 0x2a, - 0x86, 0x99, 0x55, 0x66, 0x64, 0xa2, 0x5f, 0x81, 0x6c, 0x62, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, - 0x1b, 0x38, 0xd8, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x61, 0xab, 0xc8, 0x33, 0xe3, 0x01, + 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x88, 0x38, 0x88, 0x05, 0x15, 0x95, 0x49, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x4f, 0xcc, 0xcb, 0xcb, 0x2f, 0x49, 0x2c, 0xc9, 0xcc, + 0xcf, 0x83, 0xea, 0x51, 0x92, 0xe7, 0x92, 0x0d, 0x04, 0x59, 0x18, 0x5c, 0x52, 0x94, 0xe2, 0x04, + 0xb6, 0xc1, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, + 0x29, 0x84, 0x4b, 0x0e, 0x97, 0x82, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x21, 0x23, 0x2e, 0xf6, + 0x44, 0x88, 0x90, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, + 0x97, 0x41, 0x15, 0x07, 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, 0xc1, 0x14, 0x2a, 0xc9, 0x72, 0x49, + 0x83, 0x4d, 0x0d, 0xc9, 0x2f, 0x49, 0xcc, 0x81, 0x1b, 0x9d, 0x02, 0xb3, 0x34, 0x81, 0x4b, 0x06, + 0xbb, 0x34, 0xd4, 0x4a, 0x07, 0x2e, 0x9e, 0x12, 0x90, 0x54, 0x3c, 0x38, 0x50, 0x52, 0xa0, 0xf6, + 0xca, 0x9e, 0xb8, 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x28, 0xc4, 0xee, 0xe2, 0x94, 0x6c, 0xbd, + 0xcc, 0x7c, 0xfd, 0xdc, 0xc4, 0x92, 0x0c, 0x3d, 0xcf, 0xbc, 0x92, 0x20, 0x6e, 0xb0, 0x16, 0x88, + 0x49, 0x46, 0x47, 0x98, 0xb8, 0x58, 0xc1, 0x56, 0x08, 0xcd, 0x61, 0xe4, 0x12, 0xc4, 0xf0, 0x9c, + 0x90, 0x81, 0x1e, 0x46, 0xd0, 0xeb, 0xe1, 0x0d, 0x28, 0x29, 0x43, 0x12, 0x74, 0x40, 0xbc, 0xa1, + 0xa4, 0xd4, 0x74, 0xf9, 0xc9, 0x64, 0x26, 0x19, 0x21, 0x29, 0x7d, 0xcc, 0x64, 0x00, 0x0d, 0x29, + 0xa1, 0xd9, 0x8c, 0x5c, 0xfc, 0x68, 0xc1, 0x20, 0xa4, 0x87, 0xcb, 0x2a, 0xec, 0xc1, 0x29, 0xa5, + 0x4f, 0xb4, 0x7a, 0xa8, 0xc3, 0xd4, 0xc1, 0x0e, 0x53, 0x14, 0x92, 0xc7, 0xe2, 0x30, 0xe4, 0x80, + 0x77, 0xf2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, + 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, + 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0x60, 0xb0, 0x21, 0xba, 0x3e, 0x89, 0x49, + 0xc5, 0x30, 0x03, 0xcb, 0x8c, 0x4c, 0xf4, 0x2b, 0x50, 0x8c, 0xad, 0x2c, 0x48, 0x2d, 0x4e, 0x62, + 0x03, 0xa7, 0x4a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0x0c, 0x0a, 0x2f, 0x18, 0x03, 0x00, 0x00, } @@ -157,6 +245,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // StrdBurnerAddress queries the address of the strdburner module StrdBurnerAddress(ctx context.Context, in *QueryStrdBurnerAddressRequest, opts ...grpc.CallOption) (*QueryStrdBurnerAddressResponse, error) + // StrdBurnerAddress queries the address of the strdburner module + TotalStrdBurned(ctx context.Context, in *QueryTotalStrdBurnedRequest, opts ...grpc.CallOption) (*QueryTotalStrdBurnedResponse, error) } type queryClient struct { @@ -176,10 +266,21 @@ func (c *queryClient) StrdBurnerAddress(ctx context.Context, in *QueryStrdBurner return out, nil } +func (c *queryClient) TotalStrdBurned(ctx context.Context, in *QueryTotalStrdBurnedRequest, opts ...grpc.CallOption) (*QueryTotalStrdBurnedResponse, error) { + out := new(QueryTotalStrdBurnedResponse) + err := c.cc.Invoke(ctx, "/stride.strdburner.Query/TotalStrdBurned", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // StrdBurnerAddress queries the address of the strdburner module StrdBurnerAddress(context.Context, *QueryStrdBurnerAddressRequest) (*QueryStrdBurnerAddressResponse, error) + // StrdBurnerAddress queries the address of the strdburner module + TotalStrdBurned(context.Context, *QueryTotalStrdBurnedRequest) (*QueryTotalStrdBurnedResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -189,6 +290,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) StrdBurnerAddress(ctx context.Context, req *QueryStrdBurnerAddressRequest) (*QueryStrdBurnerAddressResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StrdBurnerAddress not implemented") } +func (*UnimplementedQueryServer) TotalStrdBurned(ctx context.Context, req *QueryTotalStrdBurnedRequest) (*QueryTotalStrdBurnedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalStrdBurned not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -212,6 +316,24 @@ func _Query_StrdBurnerAddress_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_TotalStrdBurned_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalStrdBurnedRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalStrdBurned(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stride.strdburner.Query/TotalStrdBurned", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalStrdBurned(ctx, req.(*QueryTotalStrdBurnedRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "stride.strdburner.Query", HandlerType: (*QueryServer)(nil), @@ -220,6 +342,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "StrdBurnerAddress", Handler: _Query_StrdBurnerAddress_Handler, }, + { + MethodName: "TotalStrdBurned", + Handler: _Query_TotalStrdBurned_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "stride/strdburner/query.proto", @@ -278,6 +404,62 @@ func (m *QueryStrdBurnerAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryTotalStrdBurnedRequest) 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 *QueryTotalStrdBurnedRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalStrdBurnedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryTotalStrdBurnedResponse) 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 *QueryTotalStrdBurnedResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalStrdBurnedResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalBurned.Size() + i -= size + if _, err := m.TotalBurned.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -311,6 +493,26 @@ func (m *QueryStrdBurnerAddressResponse) Size() (n int) { return n } +func (m *QueryTotalStrdBurnedRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryTotalStrdBurnedResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TotalBurned.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -449,6 +651,140 @@ func (m *QueryStrdBurnerAddressResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTotalStrdBurnedRequest) 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: QueryTotalStrdBurnedRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalStrdBurnedRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryTotalStrdBurnedResponse) 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: QueryTotalStrdBurnedResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalStrdBurnedResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBurned", 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.TotalBurned.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/strdburner/types/query.pb.gw.go b/x/strdburner/types/query.pb.gw.go index dc1143236c..64ef5e65ae 100644 --- a/x/strdburner/types/query.pb.gw.go +++ b/x/strdburner/types/query.pb.gw.go @@ -51,6 +51,24 @@ func local_request_Query_StrdBurnerAddress_0(ctx context.Context, marshaler runt } +func request_Query_TotalStrdBurned_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalStrdBurnedRequest + var metadata runtime.ServerMetadata + + msg, err := client.TotalStrdBurned(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalStrdBurned_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalStrdBurnedRequest + var metadata runtime.ServerMetadata + + msg, err := server.TotalStrdBurned(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -80,6 +98,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TotalStrdBurned_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TotalStrdBurned_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalStrdBurned_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +182,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TotalStrdBurned_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TotalStrdBurned_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalStrdBurned_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_StrdBurnerAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "strdburner", "address"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_TotalStrdBurned_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stride", "strdburner", "total_burned"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_StrdBurnerAddress_0 = runtime.ForwardResponseMessage + + forward_Query_TotalStrdBurned_0 = runtime.ForwardResponseMessage ) From eb407d1ee7e48e40f6aefcb4f29cd5dac1cdab6e Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 21:03:12 +0200 Subject: [PATCH 049/115] fix ExactArgs in clis for x/auction --- x/auction/client/cli/tx.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 3d297fc5a5..dda0a8c4e2 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -44,7 +44,7 @@ Example: $ %[1]s tx %[2]s place-bid auctionName 123 1000000 --from mykey `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -92,7 +92,7 @@ Example: $ %[1]s tx %[2]s create-auction my-auction ibc/DEADBEEF true 0.95 1000000 --from admin `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(4), + Args: cobra.ExactArgs(7), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -142,7 +142,7 @@ Example: $ %[1]s tx %[2]s update-auction auctionName true 0.97 500000 --from admin `, version.AppName, types.ModuleName), ), - Args: cobra.ExactArgs(4), + Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { From 2ba4b33560705b1530b8370d74ae574b28835cd7 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 17 Dec 2024 21:14:42 +0200 Subject: [PATCH 050/115] emit event when bid is accepted --- x/auction/keeper/auction_type.go | 13 ++++++++++++- x/auction/types/events.go | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 x/auction/types/events.go diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index b7f22d5113..f8c770e74e 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -97,7 +97,18 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type return fmt.Errorf("failed to update auction stats") } - // TODO emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeBidAccepted, + sdk.NewAttribute(types.AttributeKeyAuctionName, auction.Name), + sdk.NewAttribute(types.AttributeKeyBidder, bid.Bidder), + sdk.NewAttribute(types.AttributeKeyPaymentAmount, bid.PaymentTokenAmount.String()), + sdk.NewAttribute(types.AttributeKeyPaymentDenom, auction.PaymentDenom), + sdk.NewAttribute(types.AttributeKeySellingAmount, bid.SellingTokenAmount.String()), + sdk.NewAttribute(types.AttributeKeySellingDenom, auction.SellingDenom), + sdk.NewAttribute(types.AttributeKeyPrice, discountedPrice.String()), + ), + ) return nil } diff --git a/x/auction/types/events.go b/x/auction/types/events.go new file mode 100644 index 0000000000..49e8dbc64a --- /dev/null +++ b/x/auction/types/events.go @@ -0,0 +1,15 @@ +package types + +// Event types and attribute keys for auction module +const ( + EventTypeBidPlaced = "bid_placed" + EventTypeBidAccepted = "bid_accepted" + + AttributeKeyAuctionName = "auction_name" + AttributeKeyBidder = "bidder" + AttributeKeyPaymentAmount = "payment_amount" + AttributeKeyPaymentDenom = "payment_denom" + AttributeKeySellingAmount = "selling_amount" + AttributeKeySellingDenom = "selling_denom" + AttributeKeyPrice = "discounted_price" +) From 429b98550938e919cbaaf5857476c3f553eb9abb Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 10:40:33 +0200 Subject: [PATCH 051/115] fix linter ci --- x/icqoracle/deps/osmomath/decimal.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x/icqoracle/deps/osmomath/decimal.go b/x/icqoracle/deps/osmomath/decimal.go index d84623b7d4..2515e1e2eb 100644 --- a/x/icqoracle/deps/osmomath/decimal.go +++ b/x/icqoracle/deps/osmomath/decimal.go @@ -41,10 +41,12 @@ var ( defaultBigDecPrecisionReuse = new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision), nil) precisionReuseSDKDec = new(big.Int).Exp(big.NewInt(10), big.NewInt(DecPrecision), nil) + //nolint:unused bigDecDecPrecision = new(big.Int).Mul(defaultBigDecPrecisionReuse, precisionReuseSDKDec) squaredPrecisionReuse = new(big.Int).Mul(defaultBigDecPrecisionReuse, defaultBigDecPrecisionReuse) bigDecDecPrecisionFactorDiff = new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision-DecPrecision), nil) + //nolint:unused tenTimesPrecision = new(big.Int).Exp(big.NewInt(10), big.NewInt(BigDecPrecision+1), nil) fivePrecision = new(big.Int).Quo(defaultBigDecPrecisionReuse, big.NewInt(2)) fivePrecisionSDKDec = new(big.Int).Quo(precisionReuseSDKDec, big.NewInt(2)) @@ -52,8 +54,9 @@ var ( precisionMultipliers []*big.Int zeroInt = big.NewInt(0) oneInt = big.NewInt(1) - fiveInt = big.NewInt(5) - tenInt = big.NewInt(10) + //nolint:unused + fiveInt = big.NewInt(5) + tenInt = big.NewInt(10) // log_2(e) // From: https://www.wolframalpha.com/input?i=log_2%28e%29+with+37+digits @@ -864,6 +867,8 @@ func chopPrecisionAndRoundSdkDec(d *big.Int) *big.Int { // chopPrecisionAndRoundUpDec removes DecPrecision amount of rightmost digits and rounds up. // Non-mutative. +// +//nolint:unused func chopPrecisionAndRoundUpDec(d *big.Int) *big.Int { copy := new(big.Int).Set(d) return chopPrecisionAndRoundUpMut(copy, precisionReuseSDKDec) From 45bf5a4b23f64f52221948b21f68013606e0452c Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 19:55:04 +0200 Subject: [PATCH 052/115] fix selling token availability check in fcfs bid handler --- x/auction/keeper/auction_type.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index c9f9e58824..3aa32ff08c 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -21,14 +21,14 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type // Get token amount being auctioned off moduleAddr := k.accountKeeper.GetModuleAddress(types.ModuleName) balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.SellingDenom) - tokenAmountAvailable := balance.Amount + sellingAmountAvailable := balance.Amount - // Verify auction has enough tokens to service the bid amount - if bid.PaymentTokenAmount.GT(tokenAmountAvailable) { - return fmt.Errorf("bid wants %s%s but auction has only %s%s", - bid.PaymentTokenAmount.String(), + // Verify auction has enough sellingtokens to service the bid + if bid.SellingTokenAmount.GT(sellingAmountAvailable) { + return fmt.Errorf("bid wants to buy %s%s but auction has only %s%s", + bid.SellingTokenAmount.String(), auction.SellingDenom, - tokenAmountAvailable.String(), + sellingAmountAvailable.String(), auction.SellingDenom, ) } From 3f51aa61dec4a72655c355d48cfafa0c0350b27d Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 20:09:33 +0200 Subject: [PATCH 053/115] impl admin checks --- proto/stride/icqoracle/tx.proto | 8 +-- utils/utils.go | 14 ++--- x/auction/keeper/msg_server.go | 4 -- x/auction/types/msgs.go | 10 ++-- x/icqoracle/keeper/icq.go | 12 ++-- x/icqoracle/types/msgs.go | 24 ++++---- x/icqoracle/types/tx.pb.go | 102 ++++++++++++++++---------------- 7 files changed, 86 insertions(+), 88 deletions(-) diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 184743bf08..2a1624ed8d 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -23,10 +23,10 @@ service Msg { // MsgRegisterTokenPriceQuery defines the message for adding a new token to // track prices message MsgRegisterTokenPriceQuery { - option (cosmos.msg.v1.signer) = "sender"; + option (cosmos.msg.v1.signer) = "admin"; option (amino.name) = "icqoracle/MsgRegisterTokenPriceQuery"; - string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Token denom on Stride string base_denom = 2; @@ -45,10 +45,10 @@ message MsgRegisterTokenPriceQueryResponse {} // MsgRemoveTokenPriceQuery defines the message for removing a token from price // tracking message MsgRemoveTokenPriceQuery { - option (cosmos.msg.v1.signer) = "sender"; + option (cosmos.msg.v1.signer) = "admin"; option (amino.name) = "icqoracle/MsgRemoveTokenPriceQuery"; - string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // Token denom on Stride string base_denom = 2; // Quote denom on Stride diff --git a/utils/utils.go b/utils/utils.go index ada62b08a8..1765b22029 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -20,7 +20,6 @@ import ( config "github.com/Stride-Labs/stride/v24/cmd/strided/config" icacallbacktypes "github.com/Stride-Labs/stride/v24/x/icacallbacks/types" - icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" recordstypes "github.com/Stride-Labs/stride/v24/x/records/types" ) @@ -234,9 +233,10 @@ func LogWithHostZone(chainId string, s string, a ...any) string { // Ex: // // | uosmo/ustrd | string -func LogWithPriceToken(tokenPrice icqoracletypes.TokenPrice, s string, a ...any) string { +func LogWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, s string, a ...any, +) string { msg := fmt.Sprintf(s, a...) - return fmt.Sprintf("| %s/%s/%s | %s", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, msg) + return fmt.Sprintf("| %s/%s/%s | %s", baseDenom, quoteDenom, osmosisPoolId, msg) } // Returns a log string with a chain Id and callback as a prefix @@ -244,9 +244,9 @@ func LogWithPriceToken(tokenPrice icqoracletypes.TokenPrice, s string, a ...any) // Format: // // | uosmo/ustrd | {CALLBACK_ID} {CALLBACK_TYPE} | string -func logCallbackWithPriceToken(tokenPrice icqoracletypes.TokenPrice, callbackId string, callbackType string, s string, a ...any) string { +func logCallbackWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, callbackId string, callbackType string, s string, a ...any) string { msg := fmt.Sprintf(s, a...) - return fmt.Sprintf("| %s/%s/%s | %s %s | %s", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, strings.ToUpper(callbackId), callbackType, msg) + return fmt.Sprintf("| %s/%s/%s | %s %s | %s", baseDenom, quoteDenom, osmosisPoolId, strings.ToUpper(callbackId), callbackType, msg) } // Returns a log string with a chain Id and callback as a prefix @@ -296,8 +296,8 @@ func LogICQCallbackWithHostZone(chainId string, callbackId string, s string, a . // Ex: // // | COSMOSHUB-4 | WITHDRAWALHOSTBALANCE ICQCALLBACK | string -func LogICQCallbackWithPriceToken(tokenPrice icqoracletypes.TokenPrice, callbackId string, s string, a ...any) string { - return logCallbackWithPriceToken(tokenPrice, callbackId, "ICQCALLBACK", s, a...) +func LogICQCallbackWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, callbackId string, s string, a ...any) string { + return logCallbackWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, callbackId, "ICQCALLBACK", s, a...) } // Returns a log header string with a dash padding on either side diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index cd81c8c061..3e9f5306b3 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -37,8 +37,6 @@ func (ms msgServer) PlaceBid(goCtx context.Context, msg *types.MsgPlaceBid) (*ty func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO check admin - _, err := ms.Keeper.GetAuction(ctx, msg.AuctionName) if err == nil { return nil, types.ErrAuctionAlreadyExists.Wrapf("auction with name '%s' already exists", msg.AuctionName) @@ -69,8 +67,6 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuction) (*types.MsgUpdateAuctionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO check admin - auction, err := ms.Keeper.GetAuction(ctx, msg.AuctionName) if err != nil { return nil, types.ErrAuctionDoesntExist.Wrapf("cannot find auction with name '%s'", msg.AuctionName) diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 0797b72d07..d7f0736b2d 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -9,6 +9,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + + "github.com/Stride-Labs/stride/v24/utils" ) const ( @@ -139,8 +141,8 @@ func (msg *MsgCreateAuction) GetSignBytes() []byte { } func (msg *MsgCreateAuction) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid admin address (%s)", err) + if err := utils.ValidateAdminAddress(msg.Admin); err != nil { + return err } if msg.AuctionName == "" { return errors.New("auction-name must be specified") @@ -218,8 +220,8 @@ func (msg *MsgUpdateAuction) GetSignBytes() []byte { } func (msg *MsgUpdateAuction) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Admin); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + if err := utils.ValidateAdminAddress(msg.Admin); err != nil { + return err } if msg.AuctionName == "" { return errors.New("auction-name must be specified") diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index ed7ec20a4a..4305332739 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -59,19 +59,19 @@ func (k Keeper) SubmitOsmosisClPoolICQ( ctx sdk.Context, tokenPrice types.TokenPrice, ) error { - k.Logger(ctx).Info(utils.LogWithPriceToken(tokenPrice, "Submitting OsmosisClPool ICQ")) + k.Logger(ctx).Info(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Submitting OsmosisClPool ICQ")) params := k.GetParams(ctx) osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) if err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error converting osmosis pool id '%s' to uint64, error '%s'", tokenPrice.OsmosisPoolId, err.Error())) + k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error converting osmosis pool id '%s' to uint64, error '%s'", tokenPrice.OsmosisPoolId, err.Error())) return err } tokenPriceBz, err := k.cdc.Marshal(&tokenPrice) if err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error serializing tokenPrice '%+v' to bytes, error '%s'", tokenPrice, err.Error())) + k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error serializing tokenPrice '%+v' to bytes, error '%s'", tokenPrice, err.Error())) return err } @@ -89,12 +89,12 @@ func (k Keeper) SubmitOsmosisClPoolICQ( TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, } if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error submitting OsmosisClPool ICQ, error '%s'", err.Error())) + k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error submitting OsmosisClPool ICQ, error '%s'", err.Error())) return err } if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice, true); err != nil { - k.Logger(ctx).Error(utils.LogWithPriceToken(tokenPrice, "Error updating queryInProgress=true, error '%s'", err.Error())) + k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error updating queryInProgress=true, error '%s'", err.Error())) return err } @@ -107,7 +107,7 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype return fmt.Errorf("Error deserializing query.CallbackData '%s' as TokenPrice", hex.EncodeToString(query.CallbackData)) } - k.Logger(ctx).Info(utils.LogICQCallbackWithPriceToken(tokenPrice, "OsmosisClPool", + k.Logger(ctx).Info(utils.LogICQCallbackWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "OsmosisClPool", "Starting OsmosisClPool ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 4676c5d0bd..17468c2f5c 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -4,10 +4,10 @@ import ( "errors" "strconv" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + + "github.com/Stride-Labs/stride/v24/utils" ) const ( @@ -28,9 +28,9 @@ var ( // MsgClaim // ---------------------------------------------- -func NewMsgRegisterTokenPriceQuery(sender, baseDenom, quoteDenom, poolId, osmosisBaseDenom, osmosisQuoteDenom string) *MsgRegisterTokenPriceQuery { +func NewMsgRegisterTokenPriceQuery(admin, baseDenom, quoteDenom, poolId, osmosisBaseDenom, osmosisQuoteDenom string) *MsgRegisterTokenPriceQuery { return &MsgRegisterTokenPriceQuery{ - Sender: sender, + Admin: admin, BaseDenom: baseDenom, QuoteDenom: quoteDenom, OsmosisPoolId: poolId, @@ -48,7 +48,7 @@ func (msg MsgRegisterTokenPriceQuery) Route() string { } func (msg *MsgRegisterTokenPriceQuery) GetSigners() []sdk.AccAddress { - sender, err := sdk.AccAddressFromBech32(msg.Sender) + sender, err := sdk.AccAddressFromBech32(msg.Admin) if err != nil { panic(err) } @@ -61,8 +61,8 @@ func (msg *MsgRegisterTokenPriceQuery) GetSignBytes() []byte { } func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + if err := utils.ValidateAdminAddress(msg.Admin); err != nil { + return err } if msg.BaseDenom == "" { return errors.New("base-denom must be specified") @@ -87,9 +87,9 @@ func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { // MsgRemoveTokenPriceQuery // ---------------------------------------------- -func NewMsgRemoveTokenPriceQuery(sender, baseDenom, quoteDenom, osmosisPoolId string) *MsgRemoveTokenPriceQuery { +func NewMsgRemoveTokenPriceQuery(admin, baseDenom, quoteDenom, osmosisPoolId string) *MsgRemoveTokenPriceQuery { return &MsgRemoveTokenPriceQuery{ - Sender: sender, + Admin: admin, BaseDenom: baseDenom, QuoteDenom: quoteDenom, OsmosisPoolId: osmosisPoolId, @@ -105,7 +105,7 @@ func (msg MsgRemoveTokenPriceQuery) Route() string { } func (msg *MsgRemoveTokenPriceQuery) GetSigners() []sdk.AccAddress { - sender, err := sdk.AccAddressFromBech32(msg.Sender) + sender, err := sdk.AccAddressFromBech32(msg.Admin) if err != nil { panic(err) } @@ -118,8 +118,8 @@ func (msg *MsgRemoveTokenPriceQuery) GetSignBytes() []byte { } func (msg *MsgRemoveTokenPriceQuery) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Sender); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address (%s)", err) + if err := utils.ValidateAdminAddress(msg.Admin); err != nil { + return err } if msg.BaseDenom == "" { return errors.New("base-denom must be specified") diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index 833c7bf01d..8dee348ce7 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -33,7 +33,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgRegisterTokenPriceQuery defines the message for adding a new token to // track prices type MsgRegisterTokenPriceQuery struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` // Token denom on Stride BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` // Quote denom on Stride @@ -79,9 +79,9 @@ func (m *MsgRegisterTokenPriceQuery) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterTokenPriceQuery proto.InternalMessageInfo -func (m *MsgRegisterTokenPriceQuery) GetSender() string { +func (m *MsgRegisterTokenPriceQuery) GetAdmin() string { if m != nil { - return m.Sender + return m.Admin } return "" } @@ -160,7 +160,7 @@ var xxx_messageInfo_MsgRegisterTokenPriceQueryResponse proto.InternalMessageInfo // MsgRemoveTokenPriceQuery defines the message for removing a token from price // tracking type MsgRemoveTokenPriceQuery struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` // Token denom on Stride BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` // Quote denom on Stride @@ -202,9 +202,9 @@ func (m *MsgRemoveTokenPriceQuery) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveTokenPriceQuery proto.InternalMessageInfo -func (m *MsgRemoveTokenPriceQuery) GetSender() string { +func (m *MsgRemoveTokenPriceQuery) GetAdmin() string { if m != nil { - return m.Sender + return m.Admin } return "" } @@ -276,37 +276,37 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 467 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0xb1, 0x6f, 0xd3, 0x40, - 0x14, 0xc6, 0xe3, 0xb4, 0x8d, 0xd4, 0x87, 0x10, 0xad, 0x01, 0xd5, 0xb5, 0x84, 0xa9, 0xac, 0x0a, - 0xa1, 0xa8, 0xf5, 0x41, 0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, - 0x9c, 0x3a, 0xc6, 0xef, 0xa9, 0x63, 0x7c, 0x9d, 0x39, 0x95, 0xcb, 0x99, 0x53, 0xf9, 0x35, 0x73, - 0x2a, 0x6f, 0x8e, 0x42, 0x99, 0xbc, 0x1d, 0xf5, 0x3d, 0x9f, 0x22, 0x71, 0xaa, 0xe3, 0x0f, 0x5f, - 0xf5, 0xfa, 0x2c, 0xb2, 0xd3, 0x62, 0xdc, 0x68, 0x8a, 0xf3, 0xe5, 0x33, 0xe3, 0x62, 0x88, 0xdc, - 0xaf, 0xe9, 0xdf, 0xfb, 0xe8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0x60, 0x42, 0x55, 0x54, - 0x04, 0x00, 0x00, + // 466 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x37, 0xdb, 0x6e, 0xa1, 0xaf, 0x88, 0x6d, 0x54, 0x9a, 0x06, 0x8c, 0x25, 0x14, 0x91, + 0xa5, 0xcd, 0xd0, 0xdd, 0x9e, 0xbc, 0xb9, 0x78, 0x11, 0x5c, 0x68, 0x53, 0x4f, 0x5e, 0x42, 0xfe, + 0x0c, 0x71, 0x70, 0x93, 0x37, 0x9d, 0xc9, 0xae, 0xed, 0x41, 0x10, 0xf1, 0xe4, 0xc9, 0x8f, 0xb2, + 0x07, 0xbf, 0x83, 0x1e, 0x8b, 0x27, 0x8f, 0xb2, 0x8b, 0xec, 0xd7, 0x90, 0xcc, 0x24, 0xed, 0xba, + 0x24, 0xa0, 0x27, 0x2f, 0xbb, 0xcc, 0xf3, 0xfc, 0xe6, 0x49, 0xe6, 0x99, 0xc9, 0xc0, 0xae, 0xc8, + 0x39, 0x8b, 0x28, 0x61, 0xe1, 0x39, 0x72, 0x3f, 0x1c, 0x51, 0x92, 0x5f, 0x38, 0x19, 0xc7, 0x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, 0x16, 0xd3, 0xee, 0xfe, 0xcd, 0x86, 0x34, 0x57, 0x65, 0xef, + 0x83, 0xdd, 0xec, 0xba, 0x54, 0x64, 0x98, 0x0a, 0x6a, 0xff, 0xd2, 0xc0, 0x90, 0x58, 0x82, 0x13, + 0xfa, 0xbf, 0xdb, 0xae, 0xe9, 0x63, 0xbd, 0xae, 0x8f, 0xa3, 0x3f, 0xfb, 0xb0, 0x57, 0xfa, 0xa8, + 0x59, 0x8a, 0x6d, 0xc3, 0x5e, 0x93, 0x57, 0x75, 0xd1, 0xfb, 0xd8, 0x86, 0xb5, 0xa1, 0x88, 0xf5, + 0x77, 0xb0, 0xd3, 0x74, 0xfe, 0x0e, 0x9c, 0xd5, 0x83, 0xef, 0x34, 0x97, 0x6c, 0x1e, 0xff, 0x0b, + 0x5d, 0xbd, 0x86, 0xfe, 0x16, 0xee, 0xd7, 0x6f, 0x47, 0xb7, 0x21, 0xae, 0x86, 0x35, 0x7b, 0x7f, + 0xcf, 0x56, 0x0f, 0x36, 0x3b, 0xef, 0x17, 0xd3, 0xae, 0x36, 0x18, 0x7e, 0x9b, 0x59, 0xda, 0xd5, + 0xcc, 0xd2, 0x7e, 0xce, 0x2c, 0xed, 0xf3, 0xdc, 0x6a, 0x5d, 0xcd, 0xad, 0xd6, 0x8f, 0xb9, 0xd5, + 0x7a, 0xd5, 0x8f, 0x59, 0xfe, 0x7a, 0x1c, 0x38, 0x21, 0x26, 0xe4, 0x4c, 0xc6, 0x1f, 0xbe, 0xf0, + 0x03, 0x41, 0xca, 0x7b, 0x62, 0xd2, 0x3b, 0x26, 0x17, 0xcb, 0xb7, 0xc5, 0x65, 0x46, 0x45, 0xb0, + 0x21, 0x3f, 0xec, 0xfe, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x44, 0x3a, 0x25, 0x4e, 0x04, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -484,10 +484,10 @@ func (m *MsgRegisterTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x12 } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) i-- dAtA[i] = 0xa } @@ -558,10 +558,10 @@ func (m *MsgRemoveTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, error i-- dAtA[i] = 0x12 } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintTx(dAtA, i, uint64(len(m.Admin))) i-- dAtA[i] = 0xa } @@ -608,7 +608,7 @@ func (m *MsgRegisterTokenPriceQuery) Size() (n int) { } var l int _ = l - l = len(m.Sender) + l = len(m.Admin) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -650,7 +650,7 @@ func (m *MsgRemoveTokenPriceQuery) Size() (n int) { } var l int _ = l - l = len(m.Sender) + l = len(m.Admin) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -715,7 +715,7 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -743,7 +743,7 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1007,7 +1007,7 @@ func (m *MsgRemoveTokenPriceQuery) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1035,7 +1035,7 @@ func (m *MsgRemoveTokenPriceQuery) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { From 4419b8ca808217c1776954e9f36c8f14914b56d6 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 20:12:01 +0200 Subject: [PATCH 054/115] improve bool parsing for enabled flag --- x/auction/client/cli/tx.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index dda0a8c4e2..6db8f19926 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -149,7 +149,10 @@ Example: return err } - enabled := args[1] == "true" + enabled, err := strconv.ParseBool(args[1]) + if err != nil { + return fmt.Errorf("cannot parse enabled as bool from '%s': %w", args[1], err) + } minBidAmount, err := strconv.ParseUint(args[3], 10, 64) if err != nil { From be789efa31c628e6faf5eb2d528a6a03201f5a2b Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 20:14:10 +0200 Subject: [PATCH 055/115] change icq timeout policy from retry to reject --- x/icqoracle/keeper/icq.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 4305332739..e194c6c4ff 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -86,7 +86,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( CallbackId: ICQCallbackID_OsmosisClPool, CallbackData: tokenPriceBz, TimeoutDuration: time.Duration(params.IcqTimeoutSec) * time.Second, - TimeoutPolicy: icqtypes.TimeoutPolicy_RETRY_QUERY_REQUEST, + TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error submitting OsmosisClPool ICQ, error '%s'", err.Error())) From 4188ddafa710aa2833e64a8628f180dafdb8df78 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 20:33:46 +0200 Subject: [PATCH 056/115] extract auction and price query validation logic into separate functions to share code between msg validation and genesis validation --- x/auction/types/genesis.go | 14 ++++------- x/auction/types/msgs.go | 31 +++++++----------------- x/auction/types/validate.go | 45 +++++++++++++++++++++++++++++++++++ x/icqoracle/types/genesis.go | 12 ++++------ x/icqoracle/types/msgs.go | 24 ++++++------------- x/icqoracle/types/validate.go | 26 ++++++++++++++++++++ 6 files changed, 96 insertions(+), 56 deletions(-) create mode 100644 x/auction/types/validate.go create mode 100644 x/icqoracle/types/validate.go diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go index 53b631d90f..e588b403c3 100644 --- a/x/auction/types/genesis.go +++ b/x/auction/types/genesis.go @@ -10,23 +10,19 @@ func DefaultGenesis() *GenesisState { } // Performs basic genesis state validation by iterating through all auctions and validating -// using ValidateBasic() since it already implements thorough validation of all auction fields +// using ValidateCreateAuctionParams() func (gs GenesisState) Validate() error { for i, auction := range gs.Auctions { - - msg := NewMsgCreateAuction( - "stride16eenchewedupsplt0ut600ed0ffstageeeervs", // dummy address, not stored in auction + err := ValidateCreateAuctionParams( auction.Name, auction.Type, auction.SellingDenom, auction.PaymentDenom, - auction.Enabled, - auction.PriceMultiplier.String(), - auction.MinBidAmount.Uint64(), + auction.PriceMultiplier, + auction.MinBidAmount, auction.Beneficiary, ) - - if err := msg.ValidateBasic(); err != nil { + if err != nil { return fmt.Errorf("invalid genesis auction at index %d: %w", i, err) } } diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index d7f0736b2d..8530a362cd 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -144,29 +144,16 @@ func (msg *MsgCreateAuction) ValidateBasic() error { if err := utils.ValidateAdminAddress(msg.Admin); err != nil { return err } - if msg.AuctionName == "" { - return errors.New("auction-name must be specified") - } - if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { - return fmt.Errorf("auction-type %d is invalid", msg.AuctionType) - } - if msg.SellingDenom == "" { - return errors.New("selling-denom must be specified") - } - if msg.PaymentDenom == "" { - return errors.New("payment-denom must be specified") - } - if !(msg.PriceMultiplier.GT(math.LegacyZeroDec()) && msg.PriceMultiplier.LTE(math.LegacyOneDec())) { - return errors.New("price-multiplier must be > 0 and <= 1 (0 > priceMultiplier >= 1)") - } - if msg.MinBidAmount.LT(math.ZeroInt()) { - return errors.New("min-bid-amount must be >= 0") - } - if _, err := sdk.AccAddressFromBech32(msg.Beneficiary); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid beneficiary address (%s)", err) - } - return nil + return ValidateCreateAuctionParams( + msg.AuctionName, + msg.AuctionType, + msg.SellingDenom, + msg.PaymentDenom, + msg.PriceMultiplier, + msg.MinBidAmount, + msg.Beneficiary, + ) } // ---------------------------------------------- diff --git a/x/auction/types/validate.go b/x/auction/types/validate.go new file mode 100644 index 0000000000..f899de4dea --- /dev/null +++ b/x/auction/types/validate.go @@ -0,0 +1,45 @@ +package types + +import ( + "errors" + fmt "fmt" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func ValidateCreateAuctionParams( + auctionName string, + auctionType AuctionType, + sellingDenom string, + paymentDenom string, + priceMultiplier math.LegacyDec, + minBidAmount math.Int, + beneficiary string, +) error { + if auctionName == "" { + return errors.New("auction-name must be specified") + } + if _, ok := AuctionType_name[int32(auctionType)]; !ok { + return fmt.Errorf("auction-type %d is invalid", auctionType) + } + if sellingDenom == "" { + return errors.New("selling-denom must be specified") + } + if paymentDenom == "" { + return errors.New("payment-denom must be specified") + } + if !(priceMultiplier.GT(math.LegacyZeroDec()) && priceMultiplier.LTE(math.LegacyOneDec())) { + return errors.New("price-multiplier must be > 0 and <= 1 (0 > priceMultiplier >= 1)") + } + if minBidAmount.LT(math.ZeroInt()) { + return errors.New("min-bid-amount must be >= 0") + } + if _, err := sdk.AccAddressFromBech32(beneficiary); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid beneficiary address (%s)", err) + } + + return nil +} diff --git a/x/icqoracle/types/genesis.go b/x/icqoracle/types/genesis.go index b40cf00bd5..bddce61281 100644 --- a/x/icqoracle/types/genesis.go +++ b/x/icqoracle/types/genesis.go @@ -10,23 +10,19 @@ func DefaultGenesis() *GenesisState { } // Performs basic genesis state validation by iterating through all token prices and validating -// using ValidateBasic() since it already implements thorough validation of the important token -// price fields. +// using ValidateTokenPriceQueryParams(). // We ignore the SpotPrice, UpdatedAt & QueryInProgress fields since they are reset in InitGenesis(). func (gs GenesisState) Validate() error { for i, tokenPrice := range gs.TokenPrices { - - msg := NewMsgRegisterTokenPriceQuery( - "stride1palmssweatykneesweakarmsareheavy8ahm9u", // dummy address, not stored in token price + err := ValidateTokenPriceQueryParams( tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, tokenPrice.OsmosisBaseDenom, tokenPrice.OsmosisQuoteDenom, ) - - if err := msg.ValidateBasic(); err != nil { - return fmt.Errorf("invalid genesis token price at index %d: %w", i, err) + if err != nil { + return fmt.Errorf("invalid genesis token price query at index %d: %w", i, err) } } return nil diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 17468c2f5c..e3b21b6551 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -64,23 +64,13 @@ func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { if err := utils.ValidateAdminAddress(msg.Admin); err != nil { return err } - if msg.BaseDenom == "" { - return errors.New("base-denom must be specified") - } - if msg.QuoteDenom == "" { - return errors.New("quote-denom must be specified") - } - if _, err := strconv.ParseUint(msg.OsmosisPoolId, 10, 64); err != nil { - return errors.New("osmosis-pool-id must be uint64") - } - if msg.OsmosisBaseDenom == "" { - return errors.New("osmosis-base-denom must be specified") - } - if msg.OsmosisQuoteDenom == "" { - return errors.New("osmosis-quote-denom must be specified") - } - - return nil + return ValidateTokenPriceQueryParams( + msg.BaseDenom, + msg.QuoteDenom, + msg.OsmosisPoolId, + msg.OsmosisBaseDenom, + msg.OsmosisQuoteDenom, + ) } // ---------------------------------------------- diff --git a/x/icqoracle/types/validate.go b/x/icqoracle/types/validate.go new file mode 100644 index 0000000000..a84a72984c --- /dev/null +++ b/x/icqoracle/types/validate.go @@ -0,0 +1,26 @@ +package types + +import ( + "errors" + "strconv" +) + +func ValidateTokenPriceQueryParams(baseDenom, quoteDenom, osmosisPoolId, osmosisBaseDenom, osmosisQuoteDenom string) error { + if baseDenom == "" { + return errors.New("base-denom must be specified") + } + if quoteDenom == "" { + return errors.New("quote-denom must be specified") + } + if _, err := strconv.ParseUint(osmosisPoolId, 10, 64); err != nil { + return errors.New("osmosis-pool-id must be uint64") + } + if osmosisBaseDenom == "" { + return errors.New("osmosis-base-denom must be specified") + } + if osmosisQuoteDenom == "" { + return errors.New("osmosis-quote-denom must be specified") + } + + return nil +} From 3390b83e3388780526b066b9099e49472045140a Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 18 Dec 2024 21:01:45 +0200 Subject: [PATCH 057/115] fix ci somehow --- x/auction/keeper/genesis.go | 13 +++++++++++-- x/auction/keeper/keeper.go | 4 ++-- x/auction/keeper/params.go | 24 +++++++++++++----------- x/auction/types/keys.go | 2 +- x/icqoracle/keeper/abci.go | 8 +++++++- x/icqoracle/keeper/genesis.go | 13 +++++++++++-- x/icqoracle/keeper/icq.go | 6 +++++- x/icqoracle/keeper/keeper.go | 10 +++++++--- x/icqoracle/keeper/params.go | 24 +++++++++++++----------- x/icqoracle/keeper/query.go | 5 ++++- x/icqoracle/types/keys.go | 2 +- 11 files changed, 75 insertions(+), 36 deletions(-) diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 417631b184..686f31a96b 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -8,7 +8,11 @@ import ( // Loads module state from genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - k.SetParams(ctx, genState.Params) + err := k.SetParams(ctx, genState.Params) + if err != nil { + panic(err) + } + for _, auction := range genState.Auctions { if err := k.SetAuction(ctx, &auction); err != nil { panic(err) @@ -18,8 +22,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { // Export's module state into genesis file func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params, err := k.GetParams(ctx) + if err != nil { + panic(err) + } + genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) + genesis.Params = params genesis.Auctions = k.GetAllAuctions(ctx) return genesis } diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 91f62951ce..a95de86169 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -13,7 +13,7 @@ import ( ) type Keeper struct { - cdc codec.BinaryCodec + cdc codec.Codec storeKey storetypes.StoreKey accountKeeper types.AccountKeeper bankKeeper types.BankKeeper @@ -21,7 +21,7 @@ type Keeper struct { } func NewKeeper( - cdc codec.BinaryCodec, + cdc codec.Codec, storeKey storetypes.StoreKey, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, diff --git a/x/auction/keeper/params.go b/x/auction/keeper/params.go index cdcf0b467c..9675b09115 100644 --- a/x/auction/keeper/params.go +++ b/x/auction/keeper/params.go @@ -6,20 +6,22 @@ import ( "github.com/Stride-Labs/stride/v24/x/auction/types" ) -// Writes params to the store -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +// GetParams get params +func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { store := ctx.KVStore(k.storeKey) - paramsBz := k.cdc.MustMarshal(¶ms) - store.Set([]byte(types.ParamsPrefix), paramsBz) + bz := store.Get([]byte(types.ParamsKey)) + params := types.Params{} + err := k.cdc.UnmarshalJSON(bz, ¶ms) + return params, err } -// Retrieves the module parameters -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { +// SetParams set params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { store := ctx.KVStore(k.storeKey) - paramsBz := store.Get([]byte(types.ParamsPrefix)) - if len(paramsBz) == 0 { - panic("module parameters not set") + bz, err := k.cdc.MarshalJSON(¶ms) + if err != nil { + return err } - k.cdc.MustUnmarshal(paramsBz, ¶ms) - return params + store.Set([]byte(types.ParamsKey), bz) + return nil } diff --git a/x/auction/types/keys.go b/x/auction/types/keys.go index c9d169fbf0..d71eee1ce5 100644 --- a/x/auction/types/keys.go +++ b/x/auction/types/keys.go @@ -11,7 +11,7 @@ const ( // RouterKey defines the routing key RouterKey = ModuleName - ParamsPrefix = "params" + ParamsKey = "params" KeyAuctionPrefix = "auction" ) diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index 05639548e4..8f6dd6eec6 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -8,7 +8,13 @@ import ( func (k Keeper) BeginBlocker(ctx sdk.Context) { // Get all token prices - params := k.GetParams(ctx) + params, err := k.GetParams(ctx) + if err != nil { + // Can't really do anything but log + // A panic would halt the chain + ctx.Logger().Error("failed to get icqoracle params: %w", err) + return + } currentTime := ctx.BlockTime() diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go index 6e0961aa03..cb31e53f76 100644 --- a/x/icqoracle/keeper/genesis.go +++ b/x/icqoracle/keeper/genesis.go @@ -11,7 +11,11 @@ import ( // Loads module state from genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - k.SetParams(ctx, genState.Params) + err := k.SetParams(ctx, genState.Params) + if err != nil { + panic(err) + } + for _, tokenPrice := range genState.TokenPrices { tokenPrice.SpotPrice = math.LegacyZeroDec() tokenPrice.UpdatedAt = time.Time{} @@ -25,8 +29,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { // Export's module state into genesis file func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params, err := k.GetParams(ctx) + if err != nil { + panic(err) + } + genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) + genesis.Params = params genesis.TokenPrices = k.GetAllTokenPrices(ctx) return genesis } diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index e194c6c4ff..a710949f83 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -61,7 +61,11 @@ func (k Keeper) SubmitOsmosisClPoolICQ( ) error { k.Logger(ctx).Info(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Submitting OsmosisClPool ICQ")) - params := k.GetParams(ctx) + params, err := k.GetParams(ctx) + if err != nil { + k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error getting module params: %s", err.Error())) + return err + } osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) if err != nil { diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 23c613516e..6bea267d09 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -16,13 +16,13 @@ import ( ) type Keeper struct { - cdc codec.BinaryCodec + cdc codec.Codec storeKey storetypes.StoreKey icqKeeper interchainquerykeeper.Keeper } func NewKeeper( - cdc codec.BinaryCodec, + cdc codec.Codec, storeKey storetypes.StoreKey, ) *Keeper { return &Keeper{ @@ -154,7 +154,11 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu } // Get price expiration timeout - priceExpirationTimeoutSec := int64(k.GetParams(ctx).PriceExpirationTimeoutSec) + params, err := k.GetParams(ctx) + if err != nil { + return math.LegacyDec{}, fmt.Errorf("error getting params: %w", err) + } + priceExpirationTimeoutSec := int64(params.PriceExpirationTimeoutSec) // Init price price = math.LegacyZeroDec() diff --git a/x/icqoracle/keeper/params.go b/x/icqoracle/keeper/params.go index 62d90a49bc..fbd5c91684 100644 --- a/x/icqoracle/keeper/params.go +++ b/x/icqoracle/keeper/params.go @@ -6,20 +6,22 @@ import ( "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) -// Writes params to the store -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +// GetParams get params +func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { store := ctx.KVStore(k.storeKey) - paramsBz := k.cdc.MustMarshal(¶ms) - store.Set([]byte(types.ParamsPrefix), paramsBz) + bz := store.Get([]byte(types.ParamsKey)) + params := types.Params{} + err := k.cdc.UnmarshalJSON(bz, ¶ms) + return params, err } -// Retrieves the module parameters -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { +// SetParams set params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { store := ctx.KVStore(k.storeKey) - paramsBz := store.Get([]byte(types.ParamsPrefix)) - if len(paramsBz) == 0 { - panic("module parameters not set") + bz, err := k.cdc.MarshalJSON(¶ms) + if err != nil { + return err } - k.cdc.MustUnmarshal(paramsBz, ¶ms) - return params + store.Set([]byte(types.ParamsKey), bz) + return nil } diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index d15560d60a..44606380f2 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -60,7 +60,10 @@ func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*t ctx := sdk.UnwrapSDKContext(goCtx) - params := k.GetParams(ctx) + params, err := k.GetParams(ctx) + if err != nil { + return nil, err + } return &types.QueryParamsResponse{ Params: params, diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index a3fa62e5cc..1008cab15d 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -11,7 +11,7 @@ const ( // RouterKey defines the routing key RouterKey = ModuleName - ParamsPrefix = "params" + ParamsKey = "params" KeyPricePrefix = "price" ) From 59a9e78528444774d05e474b7574281f3d233b71 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 19 Dec 2024 10:06:08 +0200 Subject: [PATCH 058/115] rename price_multiplier to min_price_multiplier --- proto/stride/auction/auction.proto | 5 +- proto/stride/auction/tx.proto | 10 ++- x/auction/client/cli/tx.go | 4 +- x/auction/keeper/auction_type.go | 12 +-- x/auction/keeper/msg_server.go | 4 +- x/auction/types/auction.pb.go | 83 ++++++++++---------- x/auction/types/genesis.go | 2 +- x/auction/types/msgs.go | 50 ++++++------ x/auction/types/tx.pb.go | 118 +++++++++++++++-------------- x/auction/types/validate.go | 6 +- 10 files changed, 150 insertions(+), 144 deletions(-) diff --git a/proto/stride/auction/auction.proto b/proto/stride/auction/auction.proto index df9bc73a96..91136ecd0f 100644 --- a/proto/stride/auction/auction.proto +++ b/proto/stride/auction/auction.proto @@ -30,8 +30,9 @@ message Auction { // Whether auction is active bool enabled = 5; - // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 6 [ + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle price) + // bids_floor_price = oracle_price * min_price_multiplier + string min_price_multiplier = 6 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; diff --git a/proto/stride/auction/tx.proto b/proto/stride/auction/tx.proto index 0fce1dcc2a..c58a98b9e1 100644 --- a/proto/stride/auction/tx.proto +++ b/proto/stride/auction/tx.proto @@ -75,8 +75,9 @@ message MsgCreateAuction { // Whether auction is active bool enabled = 6; - // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 7 [ + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle price) + // bids_floor_price = oracle_price * min_price_multiplier + string min_price_multiplier = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; @@ -109,8 +110,9 @@ message MsgUpdateAuction { // Whether auction is active bool enabled = 4; - // Price multiplier (e.g. 0.95 for 5% discount) - string price_multiplier = 5 [ + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle price) + // bids_floor_price = oracle_price * min_price_multiplier + string min_price_multiplier = 5 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 6db8f19926..1de5714fc0 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -83,7 +83,7 @@ Example: func CmdCreateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "create-auction [name] [selling-denom] [payment-denom] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", + Use: "create-auction [name] [selling-denom] [payment-denom] [enabled] [min-price-multiplier] [min-bid-amount] [beneficiary]", Short: "Create a new auction", Long: strings.TrimSpace( fmt.Sprintf(`Create a new auction for a specific token. @@ -133,7 +133,7 @@ Example: func CmdUpdateAuction() *cobra.Command { cmd := &cobra.Command{ - Use: "update-auction [name] [enabled] [price-multiplier] [min-bid-amount] [beneficiary]", + Use: "update-auction [name] [enabled] [min-price-multiplier] [min-bid-amount] [beneficiary]", Short: "Update an existing auction", Long: strings.TrimSpace( fmt.Sprintf(`Update an existing auction's parameters. diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index 3aa32ff08c..e34255e42a 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -38,19 +38,19 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type return err } - discountedPrice := price.Mul(auction.PriceMultiplier) + bidsFloorPrice := price.Mul(auction.MinPriceMultiplier) if bid.SellingTokenAmount.ToLegacyDec(). - Mul(discountedPrice). + Mul(bidsFloorPrice). LT(bid.PaymentTokenAmount.ToLegacyDec()) { - return fmt.Errorf("bid price too low: offered %s%s for %s%s, minimum required is %s%s (price=%s %s/%s)", + return fmt.Errorf("bid price too low: offered %s%s for %s%s, bids floor price is %s%s (price=%s %s/%s)", bid.PaymentTokenAmount.String(), auction.PaymentDenom, bid.SellingTokenAmount.String(), auction.SellingDenom, - bid.SellingTokenAmount.ToLegacyDec().Mul(discountedPrice).String(), + bid.SellingTokenAmount.ToLegacyDec().Mul(bidsFloorPrice).String(), auction.PaymentDenom, - discountedPrice.String(), + bidsFloorPrice.String(), auction.PaymentDenom, auction.SellingDenom, ) @@ -106,7 +106,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type sdk.NewAttribute(types.AttributeKeyPaymentDenom, auction.PaymentDenom), sdk.NewAttribute(types.AttributeKeySellingAmount, bid.SellingTokenAmount.String()), sdk.NewAttribute(types.AttributeKeySellingDenom, auction.SellingDenom), - sdk.NewAttribute(types.AttributeKeyPrice, discountedPrice.String()), + sdk.NewAttribute(types.AttributeKeyPrice, bidsFloorPrice.String()), ), ) diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 3e9f5306b3..c698e7e81e 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -48,7 +48,7 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc SellingDenom: msg.SellingDenom, PaymentDenom: msg.PaymentDenom, Enabled: msg.Enabled, - PriceMultiplier: msg.PriceMultiplier, + MinPriceMultiplier: msg.MinPriceMultiplier, MinBidAmount: msg.MinBidAmount, Beneficiary: msg.Beneficiary, TotalPaymentTokenReceived: math.ZeroInt(), @@ -75,7 +75,7 @@ func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuc auction.Type = msg.AuctionType auction.Enabled = msg.Enabled auction.MinBidAmount = msg.MinBidAmount - auction.PriceMultiplier = msg.PriceMultiplier + auction.MinPriceMultiplier = msg.MinPriceMultiplier auction.Beneficiary = msg.Beneficiary err = ms.Keeper.SetAuction(ctx, auction) diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index 85a2d12caf..0f902642b5 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -99,8 +99,9 @@ type Auction struct { PaymentDenom string `protobuf:"bytes,4,opt,name=payment_denom,json=paymentDenom,proto3" json:"payment_denom,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,5,opt,name=enabled,proto3" json:"enabled,omitempty"` - // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle reported + // price) bids_floor_price = oracle_price * min_price_multiplier + MinPriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=min_price_multiplier,json=minPriceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_price_multiplier"` // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` // Address to send the auction proceeds to @@ -195,40 +196,40 @@ func init() { func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_739480caccbf7be9) } var fileDescriptor_739480caccbf7be9 = []byte{ - // 519 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x1b, 0x28, 0xfb, 0xe3, 0x8d, 0x52, 0xac, 0x55, 0xf2, 0xb6, 0x92, 0x55, 0xdb, 0xa5, - 0x42, 0x5a, 0x22, 0x06, 0x27, 0x6e, 0xfd, 0x2b, 0x55, 0x8c, 0x52, 0x25, 0x1d, 0x12, 0x1c, 0x88, - 0x9c, 0xc4, 0x64, 0xd6, 0x62, 0x3b, 0x8a, 0xdd, 0x89, 0x7e, 0x0b, 0x3e, 0x0c, 0x37, 0xbe, 0xc0, - 0x8e, 0x13, 0x27, 0xc4, 0x61, 0x42, 0xed, 0x17, 0x41, 0xb1, 0xd3, 0x69, 0x13, 0x97, 0x9d, 0x62, - 0x3f, 0xef, 0xf3, 0xfc, 0x62, 0xd9, 0xef, 0x0b, 0x9a, 0x52, 0xe5, 0x34, 0x26, 0x2e, 0x9e, 0x45, - 0x8a, 0x0a, 0xbe, 0xfa, 0x3a, 0x59, 0x2e, 0x94, 0x80, 0x35, 0x53, 0x75, 0x4a, 0x75, 0x6f, 0x37, - 0x12, 0x92, 0x09, 0x19, 0xe8, 0xaa, 0x6b, 0x36, 0xc6, 0xba, 0xb7, 0x93, 0x88, 0x44, 0x18, 0xbd, - 0x58, 0x19, 0xf5, 0x70, 0x03, 0xac, 0x4d, 0x70, 0x8e, 0x99, 0x3c, 0xfc, 0x59, 0x05, 0xeb, 0x1d, - 0x83, 0x81, 0x2e, 0xa8, 0xaa, 0x79, 0x46, 0x90, 0xd5, 0xb2, 0xda, 0xb5, 0x93, 0x7d, 0xe7, 0xfe, - 0x5f, 0x9c, 0xd2, 0x36, 0x9d, 0x67, 0xc4, 0xd3, 0x46, 0x08, 0x41, 0x95, 0x63, 0x46, 0xd0, 0xa3, - 0x96, 0xd5, 0xde, 0xf4, 0xf4, 0x1a, 0x1e, 0x81, 0xa7, 0x92, 0xa4, 0x29, 0xe5, 0x49, 0x10, 0x13, - 0x2e, 0x18, 0x7a, 0xac, 0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, 0x0f, 0x3f, 0x02, 0x64, - 0xf8, 0xab, 0xa7, 0x31, 0x7c, 0x29, 0xd2, 0x18, 0x81, 0x87, 0xb0, 0x1b, 0x3a, 0xee, 0x9b, 0xb4, - 0x66, 0xfb, 0x22, 0x8d, 0x5f, 0x76, 0xc1, 0xd6, 0x9d, 0xae, 0x80, 0x4d, 0x80, 0x3a, 0x67, 0xbd, - 0xe9, 0xe8, 0xc3, 0x38, 0x98, 0x7e, 0x9a, 0x0c, 0x82, 0xb3, 0xb1, 0x3f, 0x19, 0xf4, 0x46, 0xc3, - 0xd1, 0xa0, 0x5f, 0xaf, 0xc0, 0x06, 0x78, 0x7e, 0xaf, 0x3a, 0xec, 0x0d, 0xfd, 0xba, 0xd5, 0x7d, - 0x77, 0xb5, 0xb0, 0xad, 0xeb, 0x85, 0x6d, 0xfd, 0x5d, 0xd8, 0xd6, 0xf7, 0xa5, 0x5d, 0xb9, 0x5e, - 0xda, 0x95, 0xdf, 0x4b, 0xbb, 0xf2, 0xf9, 0x55, 0x42, 0xd5, 0xf9, 0x2c, 0x74, 0x22, 0xc1, 0x5c, - 0x5f, 0xf7, 0xe2, 0xf1, 0x29, 0x0e, 0xa5, 0x5b, 0xce, 0xc6, 0xe5, 0xc9, 0x1b, 0xf7, 0xdb, 0xed, - 0x84, 0x14, 0x0d, 0x29, 0xc3, 0x35, 0xdd, 0xdf, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x7c, - 0xb8, 0x16, 0x97, 0x40, 0x03, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x3e, + 0x18, 0xc7, 0x9b, 0xdf, 0xaf, 0x6c, 0x9d, 0x37, 0xaa, 0x61, 0xb5, 0x92, 0xb7, 0x95, 0xac, 0xda, + 0x2e, 0x15, 0xd2, 0x12, 0x31, 0x38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, 0xdf, 0xa4, 0x35, 0xdb, 0x17, 0x69, 0xfc, 0xa2, 0x07, 0xb6, 0xef, 0x35, 0x07, + 0x6c, 0x01, 0xd4, 0x9d, 0xf5, 0xa7, 0xe3, 0xf7, 0xe7, 0xc1, 0xf4, 0xe3, 0x64, 0x18, 0xcc, 0xce, + 0xfd, 0xc9, 0xb0, 0x3f, 0x1e, 0x8d, 0x87, 0x83, 0xdd, 0x0a, 0x6c, 0x82, 0x67, 0x0f, 0xaa, 0xa3, + 0xfe, 0xc8, 0xdf, 0xb5, 0x7a, 0x6f, 0xaf, 0x97, 0xb6, 0x75, 0xb3, 0xb4, 0xad, 0x3f, 0x4b, 0xdb, + 0xfa, 0xb6, 0xb2, 0x2b, 0x37, 0x2b, 0xbb, 0xf2, 0x6b, 0x65, 0x57, 0x3e, 0xbd, 0x4c, 0xa8, 0xba, + 0x98, 0x87, 0x4e, 0x24, 0x98, 0xeb, 0xeb, 0x96, 0x3c, 0x39, 0xc3, 0xa1, 0x74, 0xcb, 0x11, 0xb9, + 0x3a, 0x7d, 0xed, 0x7e, 0xbd, 0x1b, 0x94, 0xa2, 0x2f, 0x65, 0xb8, 0xa1, 0xdb, 0xfc, 0xd5, 0xdf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x69, 0x7d, 0xc8, 0xb0, 0x47, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -312,9 +313,9 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a { - size := m.PriceMultiplier.Size() + size := m.MinPriceMultiplier.Size() i -= size - if _, err := m.PriceMultiplier.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.MinPriceMultiplier.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintAuction(dAtA, i, uint64(size)) @@ -404,7 +405,7 @@ func (m *Auction) Size() (n int) { if m.Enabled { n += 2 } - l = m.PriceMultiplier.Size() + l = m.MinPriceMultiplier.Size() n += 1 + l + sovAuction(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovAuction(uint64(l)) @@ -641,7 +642,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { m.Enabled = bool(v != 0) case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinPriceMultiplier", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -669,7 +670,7 @@ func (m *Auction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.PriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinPriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/auction/types/genesis.go b/x/auction/types/genesis.go index e588b403c3..981feb11b9 100644 --- a/x/auction/types/genesis.go +++ b/x/auction/types/genesis.go @@ -18,7 +18,7 @@ func (gs GenesisState) Validate() error { auction.Type, auction.SellingDenom, auction.PaymentDenom, - auction.PriceMultiplier, + auction.MinPriceMultiplier, auction.MinBidAmount, auction.Beneficiary, ) diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 8530a362cd..4d686c8503 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -97,25 +97,25 @@ func NewMsgCreateAuction( sellingDenom string, paymentDenom string, enabled bool, - priceMultiplier string, + minPriceMultiplier string, minBidAmount uint64, beneficiary string, ) *MsgCreateAuction { - priceMultiplierDec, err := math.LegacyNewDecFromStr(priceMultiplier) + minPriceMultiplierDec, err := math.LegacyNewDecFromStr(minPriceMultiplier) if err != nil { - panic(fmt.Sprintf("cannot parse LegacyDecimal from priceMultiplier '%s'", priceMultiplier)) + panic(fmt.Sprintf("cannot parse LegacyDecimal from minPriceMultiplier '%s'", minPriceMultiplier)) } return &MsgCreateAuction{ - Admin: admin, - AuctionName: auctionName, - AuctionType: auctionType, - SellingDenom: sellingDenom, - PaymentDenom: paymentDenom, - Enabled: enabled, - PriceMultiplier: priceMultiplierDec, - MinBidAmount: math.NewIntFromUint64(minBidAmount), - Beneficiary: beneficiary, + Admin: admin, + AuctionName: auctionName, + AuctionType: auctionType, + SellingDenom: sellingDenom, + PaymentDenom: paymentDenom, + Enabled: enabled, + MinPriceMultiplier: minPriceMultiplierDec, + MinBidAmount: math.NewIntFromUint64(minBidAmount), + Beneficiary: beneficiary, } } @@ -150,7 +150,7 @@ func (msg *MsgCreateAuction) ValidateBasic() error { msg.AuctionType, msg.SellingDenom, msg.PaymentDenom, - msg.PriceMultiplier, + msg.MinPriceMultiplier, msg.MinBidAmount, msg.Beneficiary, ) @@ -165,23 +165,23 @@ func NewMsgUpdateAuction( auctionName string, auctionType AuctionType, enabled bool, - priceMultiplier string, + minPriceMultiplier string, minBidAmount uint64, beneficiary string, ) *MsgUpdateAuction { - priceMultiplierDec, err := math.LegacyNewDecFromStr(priceMultiplier) + minPriceMultiplierDec, err := math.LegacyNewDecFromStr(minPriceMultiplier) if err != nil { - panic(fmt.Sprintf("cannot parse LegacyDecimal from priceMultiplier '%s'", priceMultiplier)) + panic(fmt.Sprintf("cannot parse LegacyDecimal from minPriceMultiplier '%s'", minPriceMultiplier)) } return &MsgUpdateAuction{ - Admin: admin, - AuctionName: auctionName, - AuctionType: auctionType, - Enabled: enabled, - PriceMultiplier: priceMultiplierDec, - MinBidAmount: math.NewIntFromUint64(minBidAmount), - Beneficiary: beneficiary, + Admin: admin, + AuctionName: auctionName, + AuctionType: auctionType, + Enabled: enabled, + MinPriceMultiplier: minPriceMultiplierDec, + MinBidAmount: math.NewIntFromUint64(minBidAmount), + Beneficiary: beneficiary, } } @@ -216,8 +216,8 @@ func (msg *MsgUpdateAuction) ValidateBasic() error { if _, ok := AuctionType_name[int32(msg.AuctionType)]; !ok { return errors.New("auction-type is invalid") } - if msg.PriceMultiplier.IsZero() { - return errors.New("price-multiplier cannot be 0") + if msg.MinPriceMultiplier.IsZero() { + return errors.New("min-price-multiplier cannot be 0") } if msg.MinBidAmount.LT(math.ZeroInt()) { return errors.New("min-bid-amount must be at least 0") diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index 7398a6e778..621f6639c2 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -141,8 +141,9 @@ type MsgCreateAuction struct { PaymentDenom string `protobuf:"bytes,5,opt,name=payment_denom,json=paymentDenom,proto3" json:"payment_denom,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,6,opt,name=enabled,proto3" json:"enabled,omitempty"` - // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle reported + // price) bids_floor_price = oracle_price * min_price_multiplier + MinPriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=min_price_multiplier,json=minPriceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_price_multiplier"` // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` Beneficiary string `protobuf:"bytes,9,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` @@ -276,8 +277,9 @@ type MsgUpdateAuction struct { AuctionType AuctionType `protobuf:"varint,3,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` - // Price multiplier (e.g. 0.95 for 5% discount) - PriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=price_multiplier,json=priceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"price_multiplier"` + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle reported + // price) bids_floor_price = oracle_price * min_price_multiplier + MinPriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=min_price_multiplier,json=minPriceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_price_multiplier"` // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` Beneficiary string `protobuf:"bytes,7,opt,name=beneficiary,proto3" json:"beneficiary,omitempty"` @@ -399,50 +401,50 @@ func init() { func init() { proto.RegisterFile("stride/auction/tx.proto", fileDescriptor_07b888fb549a7ca8) } var fileDescriptor_07b888fb549a7ca8 = []byte{ - // 683 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xbf, 0x4f, 0xdb, 0x4c, - 0x18, 0x8e, 0x81, 0x04, 0x38, 0x7e, 0x7c, 0x7c, 0x06, 0x84, 0xbf, 0xf0, 0x35, 0xd0, 0x64, 0x28, - 0x42, 0xc2, 0x2e, 0xb4, 0x13, 0x43, 0x25, 0x02, 0x4b, 0x55, 0x42, 0x2b, 0x43, 0x97, 0x76, 0x88, - 0xce, 0xbe, 0xab, 0x39, 0x91, 0xbb, 0xb3, 0x7c, 0x17, 0x44, 0xb6, 0xaa, 0xdd, 0x3a, 0x75, 0xe8, - 0x3f, 0xd1, 0x8d, 0xa1, 0x4b, 0xff, 0x03, 0x46, 0xd4, 0xa9, 0xea, 0x80, 0x2a, 0x18, 0xf8, 0x37, - 0x2a, 0xfb, 0xce, 0xc1, 0x86, 0xa8, 0x41, 0x2a, 0x43, 0x17, 0xcc, 0xfb, 0xbe, 0xcf, 0xf3, 0xd8, - 0x79, 0x9e, 0x57, 0x77, 0x60, 0x4e, 0xc8, 0x88, 0x20, 0xec, 0xc0, 0xb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6, - 0xd8, 0x39, 0xba, 0xba, 0x2e, 0x3b, 0x21, 0x16, 0x5e, 0x29, 0xb9, 0xa7, 0x1e, 0xfd, 0x0a, 0x00, - 0x00, 0xff, 0xff, 0x36, 0x84, 0x29, 0x71, 0x4d, 0x07, 0x00, 0x00, + // 687 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3d, 0x4f, 0xdc, 0x4a, + 0x14, 0x5d, 0x03, 0xbb, 0xc0, 0xf0, 0xa1, 0xf7, 0xcc, 0x22, 0xfc, 0x96, 0xf7, 0x16, 0xde, 0x6e, + 0x11, 0x84, 0x84, 0x1d, 0x48, 0x2a, 0x8a, 0x48, 0x2c, 0x34, 0x51, 0xd8, 0x04, 0x19, 0x68, 0x92, + 0x62, 0x35, 0xf6, 0x4c, 0xcc, 0x88, 0x9d, 0x19, 0xcb, 0x33, 0x8b, 0xd8, 0x2e, 0x4a, 0x49, 0x95, + 0x22, 0x7f, 0x22, 0x1d, 0x45, 0x7e, 0x40, 0x4a, 0x4a, 0x94, 0x2a, 0x4a, 0x81, 0x22, 0x28, 0xf8, + 0x1b, 0x91, 0x3d, 0xe3, 0xc5, 0x86, 0x55, 0x58, 0x29, 0x14, 0x69, 0x30, 0xf7, 0xde, 0x73, 0x8e, + 0xbd, 0xe7, 0x5c, 0xcd, 0x80, 0x39, 0x21, 0x23, 0x82, 0xb0, 0x03, 0x3b, 0xbe, 0x24, 0x9c, 0x39, + 0xf2, 0xd8, 0x0e, 0x23, 0x2e, 0xb9, 0x39, 0xad, 0x06, 0xb6, 0x1e, 0x54, 0xfe, 0x86, 0x94, 0x30, + 0xee, 0x24, 0x7f, 0x15, 0xa4, 0xf2, 0x8f, 0xcf, 0x05, 0xe5, 0xa2, 0x95, 0x54, 0x8e, 0x2a, 0xf4, + 0x68, 0x4e, 0x55, 0x0e, 0x15, 0x81, 0x73, 0xb4, 0x1a, 0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 0xba, 0xdd, 0xeb, 0x2d, 0xca, 0x97, 0xe1, 0x64, 0x51, 0xf6, 0x43, 0xf4, + 0x67, 0x2f, 0x4a, 0x26, 0xde, 0x91, 0xc1, 0xe2, 0x2d, 0x3e, 0x74, 0xbc, 0xa5, 0xdf, 0x8e, 0x77, + 0xf4, 0x81, 0xe2, 0xcd, 0xa5, 0xa5, 0xe3, 0xcd, 0xf5, 0xd2, 0x78, 0xd7, 0x3e, 0x0e, 0x81, 0xe1, + 0xa6, 0x08, 0xcc, 0x6d, 0x30, 0xd6, 0x3b, 0x4e, 0xef, 0x98, 0x9e, 0x39, 0x40, 0x2a, 0xf5, 0x5f, + 0x0c, 0x53, 0x55, 0xf3, 0x0d, 0x98, 0xca, 0x9f, 0x2c, 0x8b, 0x7d, 0x58, 0x39, 0x44, 0x65, 0xe9, + 0x3e, 0x44, 0x56, 0x3c, 0xbf, 0x8d, 0xfd, 0xc4, 0x73, 0x88, 0xbe, 0xe2, 0x7d, 0xfd, 0xa8, 0x14, + 0xdf, 0x5d, 0x9f, 0x2e, 0x1b, 0x8d, 0x17, 0x67, 0x97, 0x55, 0xe3, 0xfc, 0xb2, 0x6a, 0xfc, 0xb8, + 0xac, 0x1a, 0x1f, 0xae, 0xaa, 0x85, 0xf3, 0xab, 0x6a, 0xe1, 0xdb, 0x55, 0xb5, 0xf0, 0x7a, 0x35, + 0x20, 0xf2, 0xa0, 0xe3, 0xd9, 0x3e, 0xa7, 0xce, 0x6e, 0x22, 0xba, 0xb2, 0x0d, 0x3d, 0xe1, 0xe8, + 0x0b, 0xeb, 0x68, 0xed, 0xa9, 0x73, 0x7c, 0x73, 0x79, 0x76, 0x43, 0x2c, 0xbc, 0x52, 0x72, 0x6b, + 0x3d, 0xf9, 0x19, 0x00, 0x00, 0xff, 0xff, 0x42, 0xdb, 0xea, 0x9b, 0x5b, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -721,9 +723,9 @@ func (m *MsgCreateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x42 { - size := m.PriceMultiplier.Size() + size := m.MinPriceMultiplier.Size() i -= size - if _, err := m.PriceMultiplier.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.MinPriceMultiplier.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -837,9 +839,9 @@ func (m *MsgUpdateAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 { - size := m.PriceMultiplier.Size() + size := m.MinPriceMultiplier.Size() i -= size - if _, err := m.PriceMultiplier.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.MinPriceMultiplier.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -970,7 +972,7 @@ func (m *MsgCreateAuction) Size() (n int) { if m.Enabled { n += 2 } - l = m.PriceMultiplier.Size() + l = m.MinPriceMultiplier.Size() n += 1 + l + sovTx(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovTx(uint64(l)) @@ -1010,7 +1012,7 @@ func (m *MsgUpdateAuction) Size() (n int) { if m.Enabled { n += 2 } - l = m.PriceMultiplier.Size() + l = m.MinPriceMultiplier.Size() n += 1 + l + sovTx(uint64(l)) l = m.MinBidAmount.Size() n += 1 + l + sovTx(uint64(l)) @@ -1466,7 +1468,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { m.Enabled = bool(v != 0) case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinPriceMultiplier", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1494,7 +1496,7 @@ func (m *MsgCreateAuction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.PriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinPriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1769,7 +1771,7 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { m.Enabled = bool(v != 0) case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PriceMultiplier", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinPriceMultiplier", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1797,7 +1799,7 @@ func (m *MsgUpdateAuction) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.PriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinPriceMultiplier.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/auction/types/validate.go b/x/auction/types/validate.go index f899de4dea..b5404425f1 100644 --- a/x/auction/types/validate.go +++ b/x/auction/types/validate.go @@ -15,7 +15,7 @@ func ValidateCreateAuctionParams( auctionType AuctionType, sellingDenom string, paymentDenom string, - priceMultiplier math.LegacyDec, + minPriceMultiplier math.LegacyDec, minBidAmount math.Int, beneficiary string, ) error { @@ -31,8 +31,8 @@ func ValidateCreateAuctionParams( if paymentDenom == "" { return errors.New("payment-denom must be specified") } - if !(priceMultiplier.GT(math.LegacyZeroDec()) && priceMultiplier.LTE(math.LegacyOneDec())) { - return errors.New("price-multiplier must be > 0 and <= 1 (0 > priceMultiplier >= 1)") + if !(minPriceMultiplier.GT(math.LegacyZeroDec()) && minPriceMultiplier.LTE(math.LegacyOneDec())) { + return errors.New("min-price-multiplier must be > 0 and <= 1 (0 > minPriceMultiplier >= 1)") } if minBidAmount.LT(math.ZeroInt()) { return errors.New("min-bid-amount must be >= 0") From 3b9150fe0c4109463a48687eda9b6d01861989d3 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 19 Dec 2024 10:38:37 +0200 Subject: [PATCH 059/115] refactor auction and oracle store to use prefix store --- x/auction/keeper/keeper.go | 14 ++++++++------ x/auction/types/keys.go | 12 ++++-------- x/icqoracle/keeper/keeper.go | 24 +++++++++++++----------- x/icqoracle/types/keys.go | 12 +++++++----- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index a95de86169..5cc28af10f 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -42,8 +43,9 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // SetAuction stores auction info for a token func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { - store := ctx.KVStore(k.storeKey) - key := types.AuctionKey(auction.Name) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) + key := []byte(auction.Name) + bz, err := k.cdc.Marshal(auction) if err != nil { return fmt.Errorf("error setting auction for name='%s': %w", auction.Name, err) @@ -55,8 +57,8 @@ func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { // GetAuction retrieves auction info for a token func (k Keeper) GetAuction(ctx sdk.Context, name string) (*types.Auction, error) { - store := ctx.KVStore(k.storeKey) - key := types.AuctionKey(name) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) + key := []byte(name) bz := store.Get(key) if bz == nil { @@ -73,8 +75,8 @@ func (k Keeper) GetAuction(ctx sdk.Context, name string) (*types.Auction, error) // GetAllAuctions retrieves all stored auctions func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyAuctionPrefix)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.AuctionPrefix)) defer iterator.Close() auctions := []types.Auction{} diff --git a/x/auction/types/keys.go b/x/auction/types/keys.go index d71eee1ce5..ea08ff65d7 100644 --- a/x/auction/types/keys.go +++ b/x/auction/types/keys.go @@ -1,7 +1,5 @@ package types -import fmt "fmt" - const ( ModuleName = "auction" @@ -10,11 +8,9 @@ const ( // RouterKey defines the routing key RouterKey = ModuleName - - ParamsKey = "params" - KeyAuctionPrefix = "auction" ) -func AuctionKey(auctionName string) []byte { - return []byte(fmt.Sprintf("%s|%s", KeyAuctionPrefix, auctionName)) -} +var ( + ParamsKey = []byte("params") + AuctionPrefix = []byte("auction") +) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 6bea267d09..ebbd258ec5 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -7,6 +7,7 @@ import ( "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -35,10 +36,11 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// SetTokenPrice stores price data for a token +// SetTokenPrice stores price query for a token func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { - store := ctx.KVStore(k.storeKey) - key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) + key := types.TokenPriceQueryKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + bz, err := k.cdc.Marshal(&tokenPrice) if err != nil { return err @@ -48,10 +50,10 @@ func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) erro return nil } -// RemoveTokenPrice removes price data for a token +// RemoveTokenPrice removes price query for a token func (k Keeper) RemoveTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) { store := ctx.KVStore(k.storeKey) - key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + key := types.TokenPriceQueryKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) store.Delete(key) } @@ -72,8 +74,8 @@ func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, tokenPrice types.T // GetTokenPrice retrieves price data for a token func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (types.TokenPrice, error) { - store := ctx.KVStore(k.storeKey) - key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) + key := types.TokenPriceQueryKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) bz := store.Get(key) if bz == nil { @@ -91,7 +93,7 @@ func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (typ // GetTokenPriceByDenom retrieves all price data for a base denom // Returned as a mapping of each quote denom to the spot price func (k Keeper) GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*types.TokenPrice, error) { - store := ctx.KVStore(k.storeKey) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) // Create prefix iterator for all keys starting with baseDenom iterator := sdk.KVStorePrefixIterator(store, types.TokenPriceByDenomKey(baseDenom)) @@ -186,7 +188,6 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu } // Check that quote price is not zero to prevent division by zero - if quoteTokenPrice.SpotPrice.IsZero() { foundQuoteTokenZeroPrice = true continue @@ -217,8 +218,9 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu // GetAllTokenPrices retrieves all stored token prices func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.KeyPricePrefix)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) + + iterator := sdk.KVStorePrefixIterator(store, []byte(types.PriceQueryPrefix)) defer iterator.Close() prices := []types.TokenPrice{} diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 1008cab15d..db3fc06fe0 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -10,15 +10,17 @@ const ( // RouterKey defines the routing key RouterKey = ModuleName +) - ParamsKey = "params" - KeyPricePrefix = "price" +var ( + ParamsKey = []byte("params") + PriceQueryPrefix = []byte("pricequery") ) -func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { - return []byte(fmt.Sprintf("%s|%s|%s|%s", KeyPricePrefix, baseDenom, quoteDenom, poolId)) +func TokenPriceQueryKey(baseDenom, quoteDenom, poolId string) []byte { + return []byte(fmt.Sprintf("%s|%s|%s", baseDenom, quoteDenom, poolId)) } func TokenPriceByDenomKey(baseDenom string) []byte { - return []byte(fmt.Sprintf("%s|%s", KeyPricePrefix, baseDenom)) + return []byte(baseDenom) } From a031eb4fc265d9298ac6050e8711be4589b2be5e Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 19 Dec 2024 14:07:52 +0200 Subject: [PATCH 060/115] Change reward distribution to auction off rewards - Before: Liquid stake rewards and then send them to fee collector module - After: Send rewards directly to auction module --- x/stakeibc/keeper/hooks.go | 2 +- x/stakeibc/keeper/reward_allocation.go | 82 ++++--------------- x/stakeibc/keeper/reward_allocation_test.go | 90 +++++---------------- 3 files changed, 34 insertions(+), 140 deletions(-) diff --git a/x/stakeibc/keeper/hooks.go b/x/stakeibc/keeper/hooks.go index 1953731130..b15aa862e7 100644 --- a/x/stakeibc/keeper/hooks.go +++ b/x/stakeibc/keeper/hooks.go @@ -89,7 +89,7 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInf k.TransferAllRewardTokens(ctx) } if epochInfo.Identifier == epochstypes.MINT_EPOCH { - k.AllocateHostZoneReward(ctx) + k.AllocateRewardsFromHostZones(ctx) } } diff --git a/x/stakeibc/keeper/reward_allocation.go b/x/stakeibc/keeper/reward_allocation.go index 81f96bae58..8af660f137 100644 --- a/x/stakeibc/keeper/reward_allocation.go +++ b/x/stakeibc/keeper/reward_allocation.go @@ -1,86 +1,32 @@ package keeper import ( - "fmt" - - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - + auctiontypes "github.com/Stride-Labs/stride/v24/x/auction/types" "github.com/Stride-Labs/stride/v24/x/stakeibc/types" ) -// Liquid Stake Reward Collector Balance -func (k Keeper) LiquidStakeRewardCollectorBalance(ctx sdk.Context, msgSvr types.MsgServer) bool { - k.Logger(ctx).Info("Liquid Staking reward collector balance") - rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() - rewardedTokens := k.bankKeeper.GetAllBalances(ctx, rewardCollectorAddress) - if rewardedTokens.IsEqual(sdk.Coins{}) { - k.Logger(ctx).Info("No reward to allocate from RewardCollector") - return false - } - - rewardsAccrued := false - for _, token := range rewardedTokens { - // get hostzone by reward token (in ibc denom format) - hz, err := k.GetHostZoneFromIBCDenom(ctx, token.Denom) - if err != nil { - k.Logger(ctx).Info("Token denom %s in module account is not from a supported host zone", token.Denom) - continue - } - - // liquid stake all tokens - msg := types.NewMsgLiquidStake(rewardCollectorAddress.String(), token.Amount, hz.HostDenom) - if err := msg.ValidateBasic(); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Liquid stake from reward collector address failed validate basic: %s", err.Error())) - continue - } - _, err = msgSvr.LiquidStake(ctx, msg) - if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Failed to liquid stake %s for hostzone %s: %s", token.String(), hz.ChainId, err.Error())) - continue - } - k.Logger(ctx).Info(fmt.Sprintf("Liquid staked %s for hostzone %s's accrued rewards", token.String(), hz.ChainId)) - rewardsAccrued = true - } - return rewardsAccrued -} +// AuctionOffRewardCollectorBalance transfers all balances from the reward collector module account +// to the auction module account. If the reward collector has no balance, it does nothing. +func (k Keeper) AuctionOffRewardCollectorBalance(ctx sdk.Context) { + k.Logger(ctx).Info("Auctioning reward collector balance") -// Sweep stTokens from Reward Collector to Fee Collector -func (k Keeper) SweepStTokensFromRewardCollToFeeColl(ctx sdk.Context) error { - // Send all stTokens to fee collector to distribute to delegator later rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress() - rewardCollCoins := k.bankKeeper.GetAllBalances(ctx, rewardCollectorAddress) - k.Logger(ctx).Info(fmt.Sprintf("Reward collector has %s", rewardCollCoins.String())) - stTokens := sdk.NewCoins() - for _, token := range rewardCollCoins { - // get hostzone by reward token (in stToken denom format) - isStToken := k.CheckIsStToken(ctx, token.Denom) - k.Logger(ctx).Info(fmt.Sprintf("%s is stToken: %t", token.String(), isStToken)) - if isStToken { - stTokens = append(stTokens, token) - } + rewardCollectorBalances := k.bankKeeper.GetAllBalances(ctx, rewardCollectorAddress) + if rewardCollectorBalances.Empty() { + k.Logger(ctx).Info("No rewards to auction from RewardCollector") + return } - k.Logger(ctx).Info(fmt.Sprintf("Sending %s stTokens from %s to %s", stTokens.String(), types.RewardCollectorName, authtypes.FeeCollectorName)) - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.RewardCollectorName, authtypes.FeeCollectorName, stTokens) + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.RewardCollectorName, auctiontypes.ModuleName, rewardCollectorBalances) if err != nil { - return errorsmod.Wrapf(err, "Can't send coins from module %s to module %s", types.RewardCollectorName, authtypes.FeeCollectorName) + k.Logger(ctx).Info("Cannot send rewards from RewardCollector to Auction module: %w", err) } - return nil } -// (1) liquid stake reward collector balance, then (2) sweet stTokens from reward collector to fee collector -func (k Keeper) AllocateHostZoneReward(ctx sdk.Context) { - // TODO: Move LS function to keeper method instead of message server - msgSvr := NewMsgServerImpl(k) - if rewardsFound := k.LiquidStakeRewardCollectorBalance(ctx, msgSvr); !rewardsFound { - k.Logger(ctx).Info("No accrued rewards in the reward collector account") - return - } - if err := k.SweepStTokensFromRewardCollToFeeColl(ctx); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Unable to allocate host zone reward, err: %s", err.Error())) - } +// AllocateRewardsFromHostZones auctions off the reward collector balance +func (k Keeper) AllocateRewardsFromHostZones(ctx sdk.Context) { + k.AuctionOffRewardCollectorBalance(ctx) } diff --git a/x/stakeibc/keeper/reward_allocation_test.go b/x/stakeibc/keeper/reward_allocation_test.go index e48f0ba12f..5ae49c88df 100644 --- a/x/stakeibc/keeper/reward_allocation_test.go +++ b/x/stakeibc/keeper/reward_allocation_test.go @@ -15,6 +15,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/stretchr/testify/suite" + auctiontypes "github.com/Stride-Labs/stride/v24/x/auction/types" + epochtypes "github.com/Stride-Labs/stride/v24/x/epochs/types" recordtypes "github.com/Stride-Labs/stride/v24/x/records/types" stakeibctypes "github.com/Stride-Labs/stride/v24/x/stakeibc/types" @@ -80,14 +82,14 @@ func (s *KeeperTestSuite) TestLiquidStakeRewardCollectorBalance_Success() { s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin(IbcAtom, rewardAmount)) s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin(IbcOsmo, rewardAmount)) - // Liquid stake all hostzone token then get stTokens back - rewardsAccrued := s.App.StakeibcKeeper.LiquidStakeRewardCollectorBalance(s.Ctx, s.GetMsgServer()) - s.Require().True(rewardsAccrued, "rewards should have been liquid staked") + // Send all rewrds to auction module + s.App.StakeibcKeeper.AuctionOffRewardCollectorBalance(s.Ctx) - // Reward Collector acct should have all ibc/XXX tokens converted to stTokens - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StAtom, rewardAmount) - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StOsmo, rewardAmount) + // Check Auction module balance + s.checkModuleAccountBalance(auctiontypes.ModuleName, IbcAtom, rewardAmount) + s.checkModuleAccountBalance(auctiontypes.ModuleName, IbcOsmo, rewardAmount) + // Check RewardCollector module balance s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, IbcAtom, sdkmath.ZeroInt()) s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, IbcOsmo, sdkmath.ZeroInt()) } @@ -95,74 +97,20 @@ func (s *KeeperTestSuite) TestLiquidStakeRewardCollectorBalance_Success() { func (s *KeeperTestSuite) TestLiquidStakeRewardCollectorBalance_NoRewardsAccrued() { s.SetupTestRewardAllocation() - // With no IBC tokens in the rewards collector account, the liquid stake rewards function should return false - rewardsAccrued := s.App.StakeibcKeeper.LiquidStakeRewardCollectorBalance(s.Ctx, s.GetMsgServer()) - s.Require().False(rewardsAccrued, "no rewards should have been liquid staked") - - // There should also be no stTokens in the account - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StAtom, sdkmath.ZeroInt()) - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StOsmo, sdkmath.ZeroInt()) -} - -func (s *KeeperTestSuite) TestLiquidStakeRewardCollectorBalance_BalanceDoesNotBelongToHost() { - s.SetupTestRewardAllocation() - amount := sdkmath.NewInt(1000) - - // Fund the reward collector with ibc/atom and a denom that is not registerd to a host zone - s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin(IbcAtom, amount)) - s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin("fake_denom", amount)) - - // Liquid stake should only succeed with atom - rewardsAccrued := s.App.StakeibcKeeper.LiquidStakeRewardCollectorBalance(s.Ctx, s.GetMsgServer()) - s.Require().True(rewardsAccrued, "rewards should have been liquid staked") - - // The atom should have been liquid staked + // balances should be 0 before s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, IbcAtom, sdkmath.ZeroInt()) - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StAtom, amount) - - // But the fake denom and uosmo should not have been touched - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, "fake_denom", amount) - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StOsmo, sdkmath.ZeroInt()) -} - -func (s *KeeperTestSuite) TestSweepRewardCollToFeeCollector_Success() { - s.SetupTestRewardAllocation() - rewardAmount := sdkmath.NewInt(1000) - - // Add stTokens to reward collector - s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin(StAtom, rewardAmount)) - s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin(StOsmo, rewardAmount)) - - // Sweep stTokens from Reward Collector to Fee Collector - err := s.App.StakeibcKeeper.SweepStTokensFromRewardCollToFeeColl(s.Ctx) - s.Require().NoError(err) - - // Fee Collector acct should have stTokens after they're swept there from Reward Collector - // The reward collector should have nothing - s.checkModuleAccountBalance(authtypes.FeeCollectorName, StAtom, rewardAmount) - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StAtom, sdkmath.ZeroInt()) - - s.checkModuleAccountBalance(authtypes.FeeCollectorName, StOsmo, rewardAmount) - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, StOsmo, sdkmath.ZeroInt()) -} - -func (s *KeeperTestSuite) TestSweepRewardCollToFeeCollector_NonStTokens() { - s.SetupTestRewardAllocation() - amount := sdkmath.NewInt(1000) - nonStTokenDenom := "XXX" - - // Fund reward collector account with stTokens - s.FundModuleAccount(stakeibctypes.RewardCollectorName, sdk.NewCoin(nonStTokenDenom, amount)) - - // Sweep stTokens from Reward Collector to Fee Collector - err := s.App.StakeibcKeeper.SweepStTokensFromRewardCollToFeeColl(s.Ctx) - s.Require().NoError(err) + s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, IbcAtom, sdkmath.ZeroInt()) + s.checkModuleAccountBalance(auctiontypes.ModuleName, IbcAtom, sdkmath.ZeroInt()) + s.checkModuleAccountBalance(auctiontypes.ModuleName, IbcOsmo, sdkmath.ZeroInt()) - // Reward Collector acct should still contain nonStTokenDenom after stTokens after they're swept - s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, nonStTokenDenom, amount) + // With no IBC tokens in the rewards collector account, the auction off rewards function should do nothing + s.App.StakeibcKeeper.AuctionOffRewardCollectorBalance(s.Ctx) - // Fee Collector acct should have nothing - s.checkModuleAccountBalance(authtypes.FeeCollectorName, nonStTokenDenom, sdkmath.ZeroInt()) + // balances should be 0 after + s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, IbcAtom, sdkmath.ZeroInt()) + s.checkModuleAccountBalance(stakeibctypes.RewardCollectorName, IbcAtom, sdkmath.ZeroInt()) + s.checkModuleAccountBalance(auctiontypes.ModuleName, IbcAtom, sdkmath.ZeroInt()) + s.checkModuleAccountBalance(auctiontypes.ModuleName, IbcOsmo, sdkmath.ZeroInt()) } // Test the process of a delegator claiming staking reward stTokens (tests that Fee Account can distribute arbitrary denoms) From 4fd74d4c09d0d50546f487cc25e7230d412380e9 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 19 Dec 2024 15:21:15 +0200 Subject: [PATCH 061/115] make ts-tests work again after some changes have me made to stridejs' npm scripts --- dockernet/ts-tests/README.md | 4 +++- dockernet/ts-tests/package.json | 7 ++++--- dockernet/ts-tests/pnpm-lock.yaml | 26 ++++++-------------------- dockernet/ts-tests/test/main.test.ts | 11 ++++++----- dockernet/ts-tests/vitest.config.ts | 26 ++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 dockernet/ts-tests/vitest.config.ts diff --git a/dockernet/ts-tests/README.md b/dockernet/ts-tests/README.md index d04d6a260a..05faa81347 100644 --- a/dockernet/ts-tests/README.md +++ b/dockernet/ts-tests/README.md @@ -2,7 +2,7 @@ ```bash # build stride locally and run dokcernet -(cd ../.. && make sync && make start-docker build=sgr) +(cd ../.. && make sync && make start-docker build=sgro) # install deps pnpm i @@ -23,9 +23,11 @@ IMPORTANT: `@cosmjs/*` dependencies must match the versions used by stridejs. To ### test new protobufs - go to https://github.com/Stride-Labs/stridejs + - remove `/dist` from `.gitignore` - update the config in `scripts/clone_repos.ts` to point to the new `stride/cosmos-sdk/ibc-go` version - run `pnpm i` - run `pnpm codegen` + - run `pnpm build` - run `git commit...` - run `git push` - get the current `stridejs` commit using `git rev-parse HEAD` diff --git a/dockernet/ts-tests/package.json b/dockernet/ts-tests/package.json index 0a96351a1d..3dfef7a28a 100644 --- a/dockernet/ts-tests/package.json +++ b/dockernet/ts-tests/package.json @@ -1,10 +1,11 @@ { "name": "stride-integration-tests", "version": "1.0.0", + "type": "module", "description": "integration tests for stride chain", "scripts": { - "test": "vitest run", - "test-watch": "vitest watch" + "test": "NODE_OPTIONS=--conditions=node vitest run", + "test-watch": "NODE_OPTIONS=--conditions=node vitest watch" }, "keywords": [ "wow", @@ -25,7 +26,7 @@ "bech32": "2.0.0", "jest": "29.7.0", "prettier": "3.3.3", - "stridejs": "github:Stride-Labs/stridejs#e17c404f6451bad95ef0093f2b41244248bd7ebd", + "stridejs": "github:Stride-Labs/stridejs#e949e35", "typescript": "5.5.3", "vitest": "2.0.3" }, diff --git a/dockernet/ts-tests/pnpm-lock.yaml b/dockernet/ts-tests/pnpm-lock.yaml index 6963e63875..79354fd853 100644 --- a/dockernet/ts-tests/pnpm-lock.yaml +++ b/dockernet/ts-tests/pnpm-lock.yaml @@ -42,8 +42,8 @@ importers: specifier: 3.3.3 version: 3.3.3 stridejs: - specifier: github:Stride-Labs/stridejs#e17c404f6451bad95ef0093f2b41244248bd7ebd - version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e17c404f6451bad95ef0093f2b41244248bd7ebd + specifier: github:Stride-Labs/stridejs#e949e35 + version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35 typescript: specifier: 5.5.3 version: 5.5.3 @@ -209,10 +209,6 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/runtime@7.24.8': - resolution: {integrity: sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==} - engines: {node: '>=6.9.0'} - '@babel/template@7.24.7': resolution: {integrity: sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==} engines: {node: '>=6.9.0'} @@ -1587,9 +1583,6 @@ packages: readonly-date@1.0.0: resolution: {integrity: sha512-tMKIV7hlk0h4mO3JTmmVuIlJVXjKk3Sep9Bf5OH0O+758ruuVkUy2J9SttDLm91IEX/WHlXPSpxMGjPj4beMIQ==} - regenerator-runtime@0.14.1: - resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} - require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -1676,9 +1669,9 @@ packages: std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e17c404f6451bad95ef0093f2b41244248bd7ebd: - resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e17c404f6451bad95ef0093f2b41244248bd7ebd} - version: 0.10.0-alpha + stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: + resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35} + version: 0.11.4 string-length@4.0.2: resolution: {integrity: sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==} @@ -2111,10 +2104,6 @@ snapshots: '@babel/core': 7.24.9 '@babel/helper-plugin-utils': 7.24.8 - '@babel/runtime@7.24.8': - dependencies: - regenerator-runtime: 0.14.1 - '@babel/template@7.24.7': dependencies: '@babel/code-frame': 7.24.7 @@ -3753,8 +3742,6 @@ snapshots: readonly-date@1.0.0: {} - regenerator-runtime@0.14.1: {} - require-directory@2.1.1: {} resolve-cwd@3.0.0: @@ -3838,9 +3825,8 @@ snapshots: std-env@3.7.0: {} - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e17c404f6451bad95ef0093f2b41244248bd7ebd: + stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: dependencies: - '@babel/runtime': 7.24.8 '@cosmjs/amino': 0.32.4 '@cosmjs/encoding': 0.32.4 '@cosmjs/math': 0.32.4 diff --git a/dockernet/ts-tests/test/main.test.ts b/dockernet/ts-tests/test/main.test.ts index f2c76536e6..5b69fcf64e 100644 --- a/dockernet/ts-tests/test/main.test.ts +++ b/dockernet/ts-tests/test/main.test.ts @@ -131,12 +131,13 @@ describe("x/airdrop", () => { } expect(tx.code).toBe(0); - const { airdrop } = await stridejs.query.stride.airdrop.airdrop({ - id: airdropId, - }); + const { id, earlyClaimPenalty } = + await stridejs.query.stride.airdrop.airdrop({ + id: airdropId, + }); - expect(airdrop!.id).toBe(airdropId); - expect(airdrop!.earlyClaimPenalty).toBe("0.5"); + expect(id).toBe(airdropId); + expect(earlyClaimPenalty).toBe("0.5"); }); }); diff --git a/dockernet/ts-tests/vitest.config.ts b/dockernet/ts-tests/vitest.config.ts new file mode 100644 index 0000000000..c5659342b7 --- /dev/null +++ b/dockernet/ts-tests/vitest.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + globals: true, + environment: "node", + testTimeout: 30000, + hookTimeout: 30000, + pool: "forks", + poolOptions: { + forks: { + singleFork: true, + }, + }, + server: { + deps: { + inline: ["stridejs"], + }, + }, + }, + resolve: { + alias: { + stridejs: "stridejs/dist/esm", // Force ESM path + }, + }, +}); From 75b49d1e00fb6c035d322606ae8b9fe130e3bec6 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 22 Dec 2024 12:49:39 +0200 Subject: [PATCH 062/115] wire x/strdburner in app.go --- app/app.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/app.go b/app/app.go index a0c574517e..6d13f89d47 100644 --- a/app/app.go +++ b/app/app.go @@ -133,6 +133,10 @@ import ( auctionkeeper "github.com/Stride-Labs/stride/v24/x/auction/keeper" auctiontypes "github.com/Stride-Labs/stride/v24/x/auction/types" + "github.com/Stride-Labs/stride/v24/x/strdburner" + strdburnerkeeper "github.com/Stride-Labs/stride/v24/x/strdburner/keeper" + strdburnertypes "github.com/Stride-Labs/stride/v24/x/strdburner/types" + "github.com/Stride-Labs/stride/v24/x/autopilot" autopilotkeeper "github.com/Stride-Labs/stride/v24/x/autopilot/keeper" autopilottypes "github.com/Stride-Labs/stride/v24/x/autopilot/types" @@ -245,6 +249,7 @@ var ( airdrop.AppModuleBasic{}, icqoracle.AppModuleBasic{}, auction.AppModuleBasic{}, + strdburner.AppModuleBasic{}, ) // module account permissions @@ -269,6 +274,10 @@ var ( stakedymtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, stakedymtypes.FeeAddress: nil, wasmtypes.ModuleName: {authtypes.Burner}, + icqoracletypes.ModuleName: nil, + auctiontypes.ModuleName: nil, + // strdburner module needs burn access to burn STRD tokens that are sent to it + strdburnertypes.ModuleName: {authtypes.Burner}, } ) @@ -359,6 +368,7 @@ type StrideApp struct { AirdropKeeper airdropkeeper.Keeper ICQOracleKeeper icqoraclekeeper.Keeper AuctionKeeper auctionkeeper.Keeper + StrdburnerKeeper strdburnerkeeper.Keeper mm *module.Manager sm *module.SimulationManager @@ -417,6 +427,7 @@ func NewStrideApp( airdroptypes.StoreKey, icqoracletypes.StoreKey, auctiontypes.StoreKey, + strdburnertypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -785,6 +796,14 @@ func NewStrideApp( ) auctionModule := auction.NewAppModule(appCodec, app.AuctionKeeper) + app.StrdburnerKeeper = *strdburnerkeeper.NewKeeper( + appCodec, + keys[strdburnertypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + ) + strdburnerModule := strdburner.NewAppModule(appCodec, app.StrdburnerKeeper) + // Register Gov (must be registered after stakeibc) govRouter := govtypesv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). @@ -964,6 +983,7 @@ func NewStrideApp( stakeTiaModule, icqOracleModule, auctionModule, + strdburnerModule, ) // During begin block slashing happens after distr.BeginBlocker so that @@ -1011,6 +1031,7 @@ func NewStrideApp( airdroptypes.ModuleName, icqoracletypes.ModuleName, auctiontypes.ModuleName, + strdburnertypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -1054,6 +1075,7 @@ func NewStrideApp( airdroptypes.ModuleName, icqoracletypes.ModuleName, auctiontypes.ModuleName, + strdburnertypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -1102,6 +1124,7 @@ func NewStrideApp( airdroptypes.ModuleName, icqoracletypes.ModuleName, auctiontypes.ModuleName, + strdburnertypes.ModuleName, ) app.mm.RegisterInvariants(app.CrisisKeeper) From bf2d0249fd658640a6029442caf31244e4485722 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 23 Dec 2024 19:37:03 +0200 Subject: [PATCH 063/115] Add v25 upgrade handler - Introduces v25 upgrade handler with ICQOracle parameter initialization - Adds new module store upgrades for icqoracle, strdburner, and auction Initial ICQOracle parameters: - 5 min update and expiration intervals - 2 min ICQ timeout - Osmosis chain and connection configurations --- app/app.go | 6 +++--- app/upgrades.go | 18 +++++++++++++++++ app/upgrades/v25/upgrades.go | 39 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 app/upgrades/v25/upgrades.go diff --git a/app/app.go b/app/app.go index 6d13f89d47..a7fa69bba7 100644 --- a/app/app.go +++ b/app/app.go @@ -368,7 +368,7 @@ type StrideApp struct { AirdropKeeper airdropkeeper.Keeper ICQOracleKeeper icqoraclekeeper.Keeper AuctionKeeper auctionkeeper.Keeper - StrdburnerKeeper strdburnerkeeper.Keeper + StrdBurnerKeeper strdburnerkeeper.Keeper mm *module.Manager sm *module.SimulationManager @@ -796,13 +796,13 @@ func NewStrideApp( ) auctionModule := auction.NewAppModule(appCodec, app.AuctionKeeper) - app.StrdburnerKeeper = *strdburnerkeeper.NewKeeper( + app.StrdBurnerKeeper = *strdburnerkeeper.NewKeeper( appCodec, keys[strdburnertypes.StoreKey], app.AccountKeeper, app.BankKeeper, ) - strdburnerModule := strdburner.NewAppModule(appCodec, app.StrdburnerKeeper) + strdburnerModule := strdburner.NewAppModule(appCodec, app.StrdBurnerKeeper) // Register Gov (must be registered after stakeibc) govRouter := govtypesv1beta1.NewRouter() diff --git a/app/upgrades.go b/app/upgrades.go index fbcc5f36fa..bfb35d4694 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -34,6 +34,7 @@ import ( v22 "github.com/Stride-Labs/stride/v24/app/upgrades/v22" v23 "github.com/Stride-Labs/stride/v24/app/upgrades/v23" v24 "github.com/Stride-Labs/stride/v24/app/upgrades/v24" + v25 "github.com/Stride-Labs/stride/v24/app/upgrades/v25" v3 "github.com/Stride-Labs/stride/v24/app/upgrades/v3" v4 "github.com/Stride-Labs/stride/v24/app/upgrades/v4" v5 "github.com/Stride-Labs/stride/v24/app/upgrades/v5" @@ -46,6 +47,9 @@ import ( claimtypes "github.com/Stride-Labs/stride/v24/x/claim/types" icacallbacktypes "github.com/Stride-Labs/stride/v24/x/icacallbacks/types" icaoracletypes "github.com/Stride-Labs/stride/v24/x/icaoracle/types" + auctiontypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + strdburnertypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" recordtypes "github.com/Stride-Labs/stride/v24/x/records/types" stakedymtypes "github.com/Stride-Labs/stride/v24/x/stakedym/types" stakeibctypes "github.com/Stride-Labs/stride/v24/x/stakeibc/types" @@ -324,6 +328,16 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) { ), ) + // v25 upgrade handler + app.UpgradeKeeper.SetUpgradeHandler( + v25.UpgradeName, + v25.CreateUpgradeHandler( + app.mm, + app.configurator, + app.ICQOracleKeeper, + ), + ) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err)) @@ -385,6 +399,10 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) { storeUpgrades = &storetypes.StoreUpgrades{ Added: []string{ibcwasmtypes.ModuleName, airdroptypes.ModuleName}, } + case "v25": + storeUpgrades = &storetypes.StoreUpgrades{ + Added: []string{icqoracletypes.ModuleName, strdburnertypes.ModuleName, auctiontypes.ModuleName}, + } } if storeUpgrades != nil { diff --git a/app/upgrades/v25/upgrades.go b/app/upgrades/v25/upgrades.go new file mode 100644 index 0000000000..bef164705a --- /dev/null +++ b/app/upgrades/v25/upgrades.go @@ -0,0 +1,39 @@ +package v25 + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + icqoraclekeeper "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" + icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +var UpgradeName = "v25" + +// CreateUpgradeHandler creates an SDK upgrade handler for v23 +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + icqoracleKeeper icqoraclekeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Starting upgrade v25...") + + err := icqoracleKeeper.SetParams(ctx, icqoracletypes.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-2", + UpdateIntervalSec: 5 * 60, // 5 min + PriceExpirationTimeoutSec: 5 * 60, // 5 min + IcqTimeoutSec: 2 * 60, // 2 min + }) + if err != nil { + panic(fmt.Errorf("unable to set icqoracle params: %w", err)) + } + + ctx.Logger().Info("Running module migrations...") + return mm.RunMigrations(ctx, configurator, vm) + } +} From e21786e81bd5a05c77d8cb069077787e2b889eb6 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 24 Dec 2024 12:32:27 +0200 Subject: [PATCH 064/115] add osmo to default dockernet host chains --- dockernet/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockernet/config.sh b/dockernet/config.sh index bf52f7c7a2..def4d63ed4 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -35,7 +35,7 @@ ACCESSORY_CHAINS=() if [[ "${ALL_HOST_CHAINS:-false}" == "true" ]]; then HOST_CHAINS=(GAIA EVMOS HOST) elif [[ "${#HOST_CHAINS[@]}" == "0" ]]; then - HOST_CHAINS=(GAIA) + HOST_CHAINS=(GAIA OSMO) fi REWARD_CONVERTER_HOST_ZONE=${HOST_CHAINS[0]} From b988c652fa99843638d58b62d078e59067085802 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 24 Dec 2024 12:37:28 +0200 Subject: [PATCH 065/115] fix: update token price with current block time --- x/icqoracle/keeper/icq.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index a710949f83..f935d12b42 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -133,6 +133,7 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype tokenPrice.SpotPrice = newSpotPrice tokenPrice.QueryInProgress = false + tokenPrice.UpdatedAt = ctx.BlockTime() if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { return errorsmod.Wrap(err, "Error updating spot price from query response") From 2bbebeb4e3eed8bc5a22b4c6c9e51d290d45ec62 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 24 Dec 2024 12:41:37 +0200 Subject: [PATCH 066/115] update initial PriceExpirationTimeoutSec to 10min to prevent price from expiring before icq comes back --- app/upgrades/v25/upgrades.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/upgrades/v25/upgrades.go b/app/upgrades/v25/upgrades.go index bef164705a..45d09032e6 100644 --- a/app/upgrades/v25/upgrades.go +++ b/app/upgrades/v25/upgrades.go @@ -25,9 +25,9 @@ func CreateUpgradeHandler( err := icqoracleKeeper.SetParams(ctx, icqoracletypes.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-2", - UpdateIntervalSec: 5 * 60, // 5 min - PriceExpirationTimeoutSec: 5 * 60, // 5 min - IcqTimeoutSec: 2 * 60, // 2 min + UpdateIntervalSec: 5 * 60, // 5 min + PriceExpirationTimeoutSec: 10 * 60, // 10 min + IcqTimeoutSec: 2 * 60, // 2 min }) if err != nil { panic(fmt.Errorf("unable to set icqoracle params: %w", err)) From 89958640fab3883d4b219c9b5116867684c28f02 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Tue, 24 Dec 2024 13:03:37 +0200 Subject: [PATCH 067/115] Fixes bid price comparison logic in auction handler Corrects the mathematical comparison for bid price validation to properly compare payment amount against selling amount multiplied by floor price. Adds clarifying comments explaining the price conversion between tokens and the purpose of MinPriceMultiplier to improve code readability. --- x/auction/keeper/auction_type.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index e34255e42a..65e4bb76e9 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -33,16 +33,19 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type ) } + // Note: price converts SellingToken to PaymentToken + // Any calculation down the road makes sense only if price is multiplied by a derivative of SellingToken price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.SellingDenom, auction.PaymentDenom) if err != nil { return err } + // Apply MinPriceMultiplier bidsFloorPrice := price.Mul(auction.MinPriceMultiplier) - if bid.SellingTokenAmount.ToLegacyDec(). - Mul(bidsFloorPrice). - LT(bid.PaymentTokenAmount.ToLegacyDec()) { + // if paymentAmount < sellingAmount * bidsFloorPrice + if bid.PaymentTokenAmount.ToLegacyDec().LT(bid.SellingTokenAmount.ToLegacyDec(). + Mul(bidsFloorPrice)) { return fmt.Errorf("bid price too low: offered %s%s for %s%s, bids floor price is %s%s (price=%s %s/%s)", bid.PaymentTokenAmount.String(), auction.PaymentDenom, From 31e5c977cf1ef04ea9b237b08acff7d24594e4b5 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 25 Dec 2024 20:01:23 +0200 Subject: [PATCH 068/115] dockernet: fix GET_VAL_ADDR() for sdk 0.50 --- dockernet/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockernet/config.sh b/dockernet/config.sh index def4d63ed4..bfd5aa63e4 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -512,7 +512,7 @@ GET_VAL_ADDR() { val_index=$2 MAIN_CMD=$(GET_VAR_VALUE ${chain}_MAIN_CMD) - $MAIN_CMD q staking validators | grep ${chain}_${val_index} -A 6 | grep operator | awk '{print $2}' + $MAIN_CMD q staking validators 2>&1 | grep ${chain}_${val_index} -A 6 | grep operator | awk '{print $2}' } GET_ICA_ADDR() { From d0b035238a5cdf008ee036c9ed6e92c6bb642e16 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 30 Dec 2024 10:23:06 +0200 Subject: [PATCH 069/115] icqoracle: add tests and fix stuff - add icqoracle msgserver tests - fix remove token query - refactor keeper functions to get the 3 key values rather than the token price struct --- x/icqoracle/keeper/icq.go | 4 +- x/icqoracle/keeper/keeper.go | 16 +++--- x/icqoracle/keeper/keeper_test.go | 39 +++++++++++++++ x/icqoracle/keeper/msg_server.go | 16 +++--- x/icqoracle/keeper/msg_server_test.go | 72 +++++++++++++++++++++++++++ x/icqoracle/keeper/query.go | 8 +-- x/icqoracle/types/errors.go | 12 +++++ 7 files changed, 141 insertions(+), 26 deletions(-) create mode 100644 x/icqoracle/keeper/keeper_test.go create mode 100644 x/icqoracle/keeper/msg_server_test.go create mode 100644 x/icqoracle/types/errors.go diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index f935d12b42..40bcbe43ec 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -97,7 +97,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( return err } - if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice, true); err != nil { + if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, true); err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error updating queryInProgress=true, error '%s'", err.Error())) return err } @@ -114,7 +114,7 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype k.Logger(ctx).Info(utils.LogICQCallbackWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "OsmosisClPool", "Starting OsmosisClPool ICQ callback, QueryId: %vs, QueryType: %s, Connection: %s", query.Id, query.QueryType, query.ConnectionId)) - tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) + tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) if err != nil { return errorsmod.Wrap(err, "Error getting current spot price") } diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index ebbd258ec5..4650d102ed 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -51,14 +51,14 @@ func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) erro } // RemoveTokenPrice removes price query for a token -func (k Keeper) RemoveTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) { - store := ctx.KVStore(k.storeKey) - key := types.TokenPriceQueryKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) +func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) + key := types.TokenPriceQueryKey(baseDenom, quoteDenom, osmosisPoolId) store.Delete(key) } -func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, tokenPrice types.TokenPrice, queryInProgress bool) error { - tokenPrice, err := k.GetTokenPrice(ctx, tokenPrice) +func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string, queryInProgress bool) error { + tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom, osmosisPoolId) if err != nil { return err } @@ -73,13 +73,13 @@ func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, tokenPrice types.T } // GetTokenPrice retrieves price data for a token -func (k Keeper) GetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) (types.TokenPrice, error) { +func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) (types.TokenPrice, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceQueryKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + key := types.TokenPriceQueryKey(baseDenom, quoteDenom, osmosisPoolId) bz := store.Get(key) if bz == nil { - return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%s'", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%s'", baseDenom, quoteDenom, osmosisPoolId) } var price types.TokenPrice diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go new file mode 100644 index 0000000000..4934eea7be --- /dev/null +++ b/x/icqoracle/keeper/keeper_test.go @@ -0,0 +1,39 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/Stride-Labs/stride/v24/app/apptesting" + "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +type KeeperTestSuite struct { + apptesting.AppTestHelper +} + +func (s *KeeperTestSuite) SetupTest() { + s.Setup() +} + +// Dynamically gets the MsgServer for this module's keeper +// this function must be used so that the MsgServer is always created with the most updated App context +// +// which can change depending on the type of test +// (e.g. tests with only one Stride chain vs tests with multiple chains and IBC support) +func (s *KeeperTestSuite) GetMsgServer() types.MsgServer { + return keeper.NewMsgServerImpl(s.App.ICQOracleKeeper) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +// Helper function to get a token price and confirm there's no error +func (s *KeeperTestSuite) MustGetTokenPrice(baseDenom string, quoteDenom string, osmosisPoolId string) types.TokenPrice { + tp, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, baseDenom, quoteDenom, osmosisPoolId) + s.Require().NoError(err, "no error expected when getting token price") + return tp +} diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index bbb0d60260..6bfe03d8fb 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -26,7 +26,10 @@ var _ types.MsgServer = msgServer{} func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.MsgRegisterTokenPriceQuery) (*types.MsgRegisterTokenPriceQueryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO check admin + _, err := ms.Keeper.GetTokenPrice(ctx, msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) + if err == nil { + return nil, types.ErrTokenPriceAlreadyExists.Wrapf("token price BaseDenom='%s' QuoteDenom='%s' OsmosisPoolId='%s'", msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) + } tokenPrice := types.TokenPrice{ BaseDenom: msg.BaseDenom, @@ -39,7 +42,7 @@ func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.Ms QueryInProgress: false, } - err := ms.Keeper.SetTokenPrice(ctx, tokenPrice) + err = ms.Keeper.SetTokenPrice(ctx, tokenPrice) if err != nil { return nil, err } @@ -51,14 +54,7 @@ func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.Ms func (ms msgServer) RemoveTokenPriceQuery(goCtx context.Context, msg *types.MsgRemoveTokenPriceQuery) (*types.MsgRemoveTokenPriceQueryResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO check admin - - tokenPrice := types.TokenPrice{ - BaseDenom: msg.BaseDenom, - QuoteDenom: msg.QuoteDenom, - OsmosisPoolId: msg.OsmosisPoolId, - } - ms.Keeper.RemoveTokenPrice(ctx, tokenPrice) + ms.Keeper.RemoveTokenPrice(ctx, msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) return &types.MsgRemoveTokenPriceQueryResponse{}, nil } diff --git a/x/icqoracle/keeper/msg_server_test.go b/x/icqoracle/keeper/msg_server_test.go new file mode 100644 index 0000000000..6c4bd81d98 --- /dev/null +++ b/x/icqoracle/keeper/msg_server_test.go @@ -0,0 +1,72 @@ +package keeper_test + +import ( + "time" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +func (s *KeeperTestSuite) TestRegisterTokenPriceQuery() { + // Create a new token price query + msg := types.MsgRegisterTokenPriceQuery{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "uusdc", + } + _, err := s.GetMsgServer().RegisterTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err, "no error expected when registering token price query") + + // Confirm the token price was created + tokenPrice := s.MustGetTokenPrice(msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) + + s.Require().Equal(msg.BaseDenom, tokenPrice.BaseDenom, "base denom") + s.Require().Equal(msg.QuoteDenom, tokenPrice.QuoteDenom, "quote denom") + s.Require().Equal(msg.OsmosisPoolId, tokenPrice.OsmosisPoolId, "osmosis pool id") + s.Require().Equal(msg.OsmosisBaseDenom, tokenPrice.OsmosisBaseDenom, "osmosis base denom") + s.Require().Equal(msg.OsmosisQuoteDenom, tokenPrice.OsmosisQuoteDenom, "osmosis quote denom") + s.Require().Equal(sdkmath.LegacyZeroDec(), tokenPrice.SpotPrice, "spot price") + s.Require().Equal(false, tokenPrice.QueryInProgress, "query in progress") + s.Require().Equal(time.Time{}, tokenPrice.UpdatedAt, "updated at") + + // Attempt to register it again, it should fail + _, err = s.GetMsgServer().RegisterTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorIs(err, types.ErrTokenPriceAlreadyExists) +} + +func (s *KeeperTestSuite) TestRemoveTokenPriceQuery() { + // Create a token price + tokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "uusdc", + SpotPrice: sdkmath.LegacyNewDec(1), + UpdatedAt: time.Now().UTC(), + QueryInProgress: false, + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting token price") + + // Remove the token price + msg := types.MsgRemoveTokenPriceQuery{ + BaseDenom: tokenPrice.BaseDenom, + QuoteDenom: tokenPrice.QuoteDenom, + OsmosisPoolId: tokenPrice.OsmosisPoolId, + } + _, err = s.GetMsgServer().RemoveTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err, "no error expected when removing token price query") + + // Confirm the token price was removed + tp, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) + s.Require().Error(err, "token price %+v should have been removed", tp) + + // Try to remove it again, it should still succeed + _, err = s.GetMsgServer().RemoveTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err, "no error expected when removing non-existent token price query") +} diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index 44606380f2..73b16286d8 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -20,12 +20,8 @@ func (k Keeper) TokenPrice(goCtx context.Context, req *types.QueryTokenPriceRequ } ctx := sdk.UnwrapSDKContext(goCtx) - tokenPrice := types.TokenPrice{ - BaseDenom: req.BaseDenom, - QuoteDenom: req.QuoteDenom, - OsmosisPoolId: req.PoolId, - } - price, err := k.GetTokenPrice(ctx, tokenPrice) + + price, err := k.GetTokenPrice(ctx, req.BaseDenom, req.QuoteDenom, req.PoolId) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } diff --git a/x/icqoracle/types/errors.go b/x/icqoracle/types/errors.go new file mode 100644 index 0000000000..181434f4fa --- /dev/null +++ b/x/icqoracle/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/icqoracle module sentinel errors +var ( + ErrTokenPriceAlreadyExists = sdkerrors.Register(ModuleName, 16001, "token price already exists") +) From 9150b4bdb286ca9badbe953a6374c1f5eea6057e Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 30 Dec 2024 11:28:20 +0200 Subject: [PATCH 070/115] test and fix GetTokenPriceForQuoteDenom --- x/icqoracle/keeper/keeper.go | 33 ++-- x/icqoracle/keeper/query_test.go | 283 +++++++++++++++++++++++++++++++ 2 files changed, 302 insertions(+), 14 deletions(-) create mode 100644 x/icqoracle/keeper/query_test.go diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 4650d102ed..04242f361d 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -146,15 +146,6 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu return math.LegacyDec{}, fmt.Errorf("no price for '%s'", baseDenom) } - // Get all price for quoteToken - quoteTokenPrices, err := k.GetTokenPricesByDenom(ctx, quoteDenom) - if err != nil { - return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", quoteDenom, err) - } - if len(quoteTokenPrices) == 0 { - return math.LegacyDec{}, fmt.Errorf("no price for '%s'", quoteDenom) - } - // Get price expiration timeout params, err := k.GetParams(ctx) if err != nil { @@ -162,6 +153,22 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu } priceExpirationTimeoutSec := int64(params.PriceExpirationTimeoutSec) + // Check if baseDenom already has a price for quoteDenom + foundAlreadyHasStalePrice := false + if price, ok := baseTokenPrices[quoteDenom]; ok { + if ctx.BlockTime().Unix()-price.UpdatedAt.Unix() <= priceExpirationTimeoutSec { + return price.SpotPrice, nil + } else { + foundAlreadyHasStalePrice = true + } + } + + // Get all price for quoteToken + quoteTokenPrices, err := k.GetTokenPricesByDenom(ctx, quoteDenom) + if err != nil { + return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", quoteDenom, err) + } + // Init price price = math.LegacyZeroDec() @@ -195,7 +202,6 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu // Calculate the price of 1 baseToken in quoteToken price = baseTokenPrice.SpotPrice.Quo(quoteTokenPrice.SpotPrice) - break } } @@ -203,13 +209,14 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu if price.IsZero() { return math.LegacyDec{}, fmt.Errorf( - "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v', foundQuoteTokenZeroPrice='%v')", + "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v', foundQuoteTokenZeroPrice='%v', foundAlreadyHasStalePrice='%v')", baseDenom, quoteDenom, foundCommonQuoteToken, foundBaseTokenStalePrice, foundQuoteTokenStalePrice, foundQuoteTokenZeroPrice, + foundAlreadyHasStalePrice, ) } @@ -218,9 +225,7 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu // GetAllTokenPrices retrieves all stored token prices func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - - iterator := sdk.KVStorePrefixIterator(store, []byte(types.PriceQueryPrefix)) + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), []byte(types.PriceQueryPrefix)) defer iterator.Close() prices := []types.TokenPrice{} diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go new file mode 100644 index 0000000000..9db7ec4a3d --- /dev/null +++ b/x/icqoracle/keeper/query_test.go @@ -0,0 +1,283 @@ +package keeper_test + +import ( + "time" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +func (s *KeeperTestSuite) TestQueryTokenPrice() { + // Create token price entry + baseDenom := "uatom" + quoteDenom := "uusdc" + poolId := "1" + expectedPrice := sdkmath.LegacyNewDec(1000000) + + tokenPrice := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: poolId, + SpotPrice: expectedPrice, + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice) + + // Query for the token price + req := &types.QueryTokenPriceRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + PoolId: poolId, + } + resp, err := s.App.ICQOracleKeeper.TokenPrice(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying token price") + s.Require().Equal(expectedPrice, resp.TokenPrice.SpotPrice, "token price") + + // Query with invalid request + _, err = s.App.ICQOracleKeeper.TokenPrice(sdk.WrapSDKContext(s.Ctx), nil) + s.Require().Error(err, "error expected when querying with nil request") +} + +func (s *KeeperTestSuite) TestQueryTokenPrices() { + // Create multiple token prices + expectedPrices := []types.TokenPrice{ + { + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + }, + { + BaseDenom: "uosmo", + QuoteDenom: "uusdc", + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + }, + } + + for _, price := range expectedPrices { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, price) + s.Require().NoError(err, "no error expected when setting token price %+v", price) + } + + // Query all token prices + req := &types.QueryTokenPricesRequest{} + resp, err := s.App.ICQOracleKeeper.TokenPrices(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying all token prices") + s.Require().Equal(expectedPrices, resp.TokenPrices, "token prices") + + // Query with invalid request + _, err = s.App.ICQOracleKeeper.TokenPrices(sdk.WrapSDKContext(s.Ctx), nil) + s.Require().Error(err, "error expected when querying with nil request") +} + +func (s *KeeperTestSuite) TestQueryParams() { + // Set parameters + expectedParams := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-2", + UpdateIntervalSec: 5 * 60, // 5 min + PriceExpirationTimeoutSec: 10 * 60, // 10 min + IcqTimeoutSec: 2 * 60, // 2 min + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) + s.Require().NoError(err, "no error expected when setting params") + + // Query parameters + req := &types.QueryParamsRequest{} + resp, err := s.App.ICQOracleKeeper.Params(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying params") + s.Require().Equal(expectedParams, resp.Params, "params") + + // Query with invalid request + _, err = s.App.ICQOracleKeeper.Params(sdk.WrapSDKContext(s.Ctx), nil) + s.Require().Error(err, "error expected when querying with nil request") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { + // Create token price with same quote denom + baseDenom := "uatom" + quoteDenom := "uusdc" + expectedPrice := sdkmath.LegacyNewDec(1000000) + + tokenPrice := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: "1", + SpotPrice: expectedPrice, + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice) + + // Query for token price using quote denom + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + resp, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying token price for quote denom") + s.Require().Equal(expectedPrice, resp.Price, "token price") + + // Query with invalid request + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), nil) + s.Require().Error(err, "error expected when querying with nil request") + + // Query with non-existent denom pair + reqNonExistent := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: "nonexistent", + QuoteDenom: "nonexistent", + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), reqNonExistent) + s.Require().Error(err, "error expected when querying non-existent denom pair") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { + // Create two token prices with same quote denom + baseDenom1 := "uatom" + baseDenom2 := "uosmo" + quoteDenom := "uusdc" + expectedPrice1 := sdkmath.LegacyNewDec(1000000) + expectedPrice2 := sdkmath.LegacyNewDec(2000000) + + // Set uatom price + tokenPrice1 := types.TokenPrice{ + BaseDenom: baseDenom1, + QuoteDenom: quoteDenom, + OsmosisPoolId: "1", + SpotPrice: expectedPrice1, + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice1) + + // Set uosmo price + tokenPrice2 := types.TokenPrice{ + BaseDenom: baseDenom2, + QuoteDenom: quoteDenom, + OsmosisPoolId: "2", + SpotPrice: expectedPrice2, + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) + s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice2) + + // Query for token price using a common quote denom + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom1, + QuoteDenom: baseDenom2, + } + resp, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying token price for quote denom") + s.Require().Equal(expectedPrice1.Quo(expectedPrice2), resp.Price, "token price") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { + // Set up parameters with short expiration time + params := types.Params{ + PriceExpirationTimeoutSec: 60, // 1 minute timeout + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Create token prices + baseDenom := "uatom" + quoteDenom := "uusdc" + expectedPrice := sdkmath.LegacyNewDec(1000000) + + tokenPrice := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: "1", + SpotPrice: expectedPrice, + UpdatedAt: s.Ctx.BlockTime(), // Current time + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err) + + // Fast forward block time to make price stale + s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Minute * 2)) + + // Query should fail due to stale price + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "expected error for stale price") + s.Require().Contains(err.Error(), "foundAlreadyHasStalePrice='true'", "error should indicate price calculation failure") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { + // Create token prices with zero price for quote token + baseDenom := "uatom" + quoteDenom := "uusdc" + intermediateQuote := "uosmo" + + // Set base token price + tokenPrice1 := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err) + + // Set quote token price with zero value + tokenPrice2 := types.TokenPrice{ + BaseDenom: quoteDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyZeroDec(), + UpdatedAt: s.Ctx.BlockTime(), + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) + s.Require().NoError(err) + + // Query should fail due to zero price + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "expected error for zero price") + s.Require().Contains(err.Error(), "could not calculate price", "error should indicate price calculation failure") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { + // Create token prices with different quote denoms + baseDenom := "uatom" + quoteDenom := "uusdc" + + // Set base token price with one quote denom + tokenPrice1 := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: "quote1", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err) + + // Set quote token price with different quote denom + tokenPrice2 := types.TokenPrice{ + BaseDenom: quoteDenom, + QuoteDenom: "quote2", + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) + s.Require().NoError(err) + + // Query should fail due to no common quote denom + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "expected error when no common quote denom exists") + s.Require().Contains(err.Error(), "could not calculate price", "error should indicate price calculation failure") +} From e3eb4499c670b0d8605c11b1c66b347dbfa0a9d7 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 30 Dec 2024 11:30:20 +0200 Subject: [PATCH 071/115] TestParams --- x/icqoracle/keeper/params_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 x/icqoracle/keeper/params_test.go diff --git a/x/icqoracle/keeper/params_test.go b/x/icqoracle/keeper/params_test.go new file mode 100644 index 0000000000..9ea620a238 --- /dev/null +++ b/x/icqoracle/keeper/params_test.go @@ -0,0 +1,19 @@ +package keeper_test + +import "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + +func (s *KeeperTestSuite) TestParams() { + expectedParams := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-2", + UpdateIntervalSec: 5 * 60, // 5 min + PriceExpirationTimeoutSec: 10 * 60, // 10 min + IcqTimeoutSec: 2 * 60, // 2 min + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) + s.Require().NoError(err, "should not error on set params") + + actualParams, err := s.App.ICQOracleKeeper.GetParams(s.Ctx) + s.Require().NoError(err, "should not error on get params") + s.Require().Equal(expectedParams, actualParams, "params") +} From a5b48baa7b85bfac666882ff9a98a2d2b75f54fb Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sat, 4 Jan 2025 20:34:20 +0200 Subject: [PATCH 072/115] bump cosmos-sdk from v0.47.10 to v0.47.15 --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 9a1c678b59..31f0888ef2 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/Stride-Labs/ibc-rate-limiting v1.0.0 github.com/cometbft/cometbft v0.37.11 github.com/cometbft/cometbft-db v0.8.0 - github.com/cosmos/cosmos-proto v1.0.0-beta.4 + github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.47.10 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3-0.20240228213828-cce7f56d000b @@ -45,7 +45,7 @@ require ( cosmossdk.io/api v0.3.1 // indirect cosmossdk.io/core v0.6.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/log v1.4.1 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -156,7 +156,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.3 // indirect - github.com/rs/zerolog v1.32.0 // indirect + github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect @@ -211,7 +211,7 @@ replace ( // - fix SDKv0.47 Distribution Bug // - add better mempool error on sig verification failure // TODO - Remove this patch and update Tokens in a subsequent upgrade handler - github.com/cosmos/cosmos-sdk => github.com/Stride-Labs/cosmos-sdk v0.47.10-stride-distribution-fix-0-mempool-verbose-error-3 + github.com/cosmos/cosmos-sdk => github.com/Stride-Labs/cosmos-sdk v0.47.15-stride-distribution-fix-0-mempool-verbose-error-0 // Add additional verification check to ensure an account is a BaseAccount type before converting // it to a vesting account: https://github.com/Stride-Labs/vesting/pull/1 diff --git a/go.sum b/go.sum index 995e1e65be..d01568fe14 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98ok cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= -cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= -cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= +cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= +cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= @@ -223,8 +223,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Stride-Labs/cast v0.0.3 h1:eM3n/t3hSxb+iw9LDo3r/uGBp3w4U7wPv40GKMtJ1dI= github.com/Stride-Labs/cast v0.0.3/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/Stride-Labs/cosmos-sdk v0.47.10-stride-distribution-fix-0-mempool-verbose-error-3 h1:bupzm8eL2OTYhjHJOyj5ESRhJs29xMV9lKuj1uImNc4= -github.com/Stride-Labs/cosmos-sdk v0.47.10-stride-distribution-fix-0-mempool-verbose-error-3/go.mod h1:nfj9nS6kEdlyNFdjxsVcKrCy5uyhBqEwVQxDxActPaE= +github.com/Stride-Labs/cosmos-sdk v0.47.15-stride-distribution-fix-0-mempool-verbose-error-0 h1:ea/B1ZAZvl1PnxFStU+pToMZaJ0d12/atZSjfZRv1NY= +github.com/Stride-Labs/cosmos-sdk v0.47.15-stride-distribution-fix-0-mempool-verbose-error-0/go.mod h1:TKFtiZ8PhlI1IsGzBiftDQrXZHPtISUjxw3/4Jq1GPk= github.com/Stride-Labs/ibc-rate-limiting v1.0.0 h1:Omzd5qcfdaD6mPhMgtL0+B2yBvdovdgAnBzE3P2BLzY= github.com/Stride-Labs/ibc-rate-limiting v1.0.0/go.mod h1:cvHY3wI66beMkgeHLYjyAAFfzq4V8tYYtQRxNB6VbVM= github.com/Stride-Labs/vesting v1.0.0-check-base-account h1:eFlSH1itTVb0y4DKIlukSzawfwi2XidQ8+gcwZJRxnA= @@ -335,8 +335,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU= -github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co= +github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= +github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -912,8 +912,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= From 89d3f92637a70184a5d7813414437cb9c0d18929 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 20 Jan 2025 11:22:36 +0200 Subject: [PATCH 073/115] test SubmitICQRequest in x/icqoracle --- x/icqoracle/keeper/icq.go | 12 +- x/icqoracle/keeper/icq_test.go | 346 ++++++++++++++++++++++++++ x/icqoracle/keeper/keeper.go | 4 +- x/icqoracle/keeper/keeper_test.go | 15 ++ x/icqoracle/types/expected_keepers.go | 11 + 5 files changed, 379 insertions(+), 9 deletions(-) create mode 100644 x/icqoracle/keeper/icq_test.go diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 40bcbe43ec..9350968855 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -64,19 +64,19 @@ func (k Keeper) SubmitOsmosisClPoolICQ( params, err := k.GetParams(ctx) if err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error getting module params: %s", err.Error())) - return err + return errorsmod.Wrapf(err, "Error getting module params") } osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) if err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error converting osmosis pool id '%s' to uint64, error '%s'", tokenPrice.OsmosisPoolId, err.Error())) - return err + return errorsmod.Wrapf(err, "Error converting osmosis pool id '%s' to uint64", tokenPrice.OsmosisPoolId) } tokenPriceBz, err := k.cdc.Marshal(&tokenPrice) if err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error serializing tokenPrice '%+v' to bytes, error '%s'", tokenPrice, err.Error())) - return err + return errorsmod.Wrapf(err, "Error serializing tokenPrice '%+v' to bytes", tokenPrice) } queryId := fmt.Sprintf("%s|%s|%s|%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, ctx.BlockHeight()) @@ -92,14 +92,14 @@ func (k Keeper) SubmitOsmosisClPoolICQ( TimeoutDuration: time.Duration(params.IcqTimeoutSec) * time.Second, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.icqKeeper.SubmitICQRequest(ctx, query, true); err != nil { + if err := k.IcqKeeper.SubmitICQRequest(ctx, query, true); err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error submitting OsmosisClPool ICQ, error '%s'", err.Error())) - return err + return errorsmod.Wrapf(err, "Error submitting OsmosisClPool ICQ") } if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, true); err != nil { k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error updating queryInProgress=true, error '%s'", err.Error())) - return err + return errorsmod.Wrapf(err, "Error updating queryInProgress=true") } return nil diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go new file mode 100644 index 0000000000..f3e196a231 --- /dev/null +++ b/x/icqoracle/keeper/icq_test.go @@ -0,0 +1,346 @@ +package keeper_test + +import ( + "fmt" + "strconv" + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/cosmos/gogoproto/proto" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/deps/osmomath" + deps "github.com/Stride-Labs/stride/v24/x/icqoracle/deps/types" + "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" +) + +// Mock ICQ Keeper struct +type MockICQKeeper struct { + SubmitICQRequestFn func(ctx sdk.Context, query icqtypes.Query, prove bool) error +} + +func (m MockICQKeeper) SubmitICQRequest(ctx sdk.Context, query icqtypes.Query, prove bool) error { + if m.SubmitICQRequestFn != nil { + return m.SubmitICQRequestFn(ctx, query, prove) + } + return nil +} + +// Helper function to create mock pool data +func (s *KeeperTestSuite) createMockPoolData(baseDenom string, quoteDenom string) []byte { + pool := deps.OsmosisConcentratedLiquidityPool{ + Id: 1, + CurrentTickLiquidity: math.LegacyNewDec(1000000), + Token0: baseDenom, + Token1: quoteDenom, + CurrentSqrtPrice: osmomath.NewBigDec(1000000), // This represents a price of 1.0 + CurrentTick: 0, + TickSpacing: 100, + ExponentAtPriceOne: 6, + SpreadFactor: math.LegacyNewDecWithPrec(1, 3), // 0.1% + } + + bz, err := proto.Marshal(&pool) + s.Require().NoError(err, "no error expected when marshaling mock pool data") + return bz +} + +func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQUnknownPrice() { + // Set up test parameters + tokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + } + + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Submit ICQ request + err = s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) + s.Require().ErrorContains(err, "price not found") +} + +func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { + var submittedQuery icqtypes.Query + + // Setup mock ICQ keeper with custom behavior + s.mockICQKeeper = MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + submittedQuery = query + return nil + }, + } + s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + + // Set up test parameters + tokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + } + + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err) + + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err = s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Verify tokenPrice.QueryInProgress before + s.Require().False(tokenPrice.QueryInProgress) + + // Submit ICQ request + err = s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) + s.Require().NoError(err) + + // Verify the submitted query + s.Require().Equal(params.OsmosisChainId, submittedQuery.ChainId) + s.Require().Equal(params.OsmosisConnectionId, submittedQuery.ConnectionId) + s.Require().Equal(icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, submittedQuery.QueryType) + + // Verify tokenPrice.QueryInProgress after + tokenPriceAfter, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + s.Require().NoError(err) + + s.Require().True(tokenPriceAfter.QueryInProgress) +} + +func (s *KeeperTestSuite) TestICQCallbacksRegistration() { + callbacks := s.App.ICQOracleKeeper.ICQCallbackHandler().RegisterICQCallbacks() + + // Verify the expected callbacks are registered + s.Require().True(callbacks.HasICQCallback("osmosisclpool"), "osmosisclpool callback should be registered after RegisterICQCallbacks") +} + +func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { + testCases := []struct { + name string + setup func() + tokenPrice types.TokenPrice + expectedError string + }{ + { + name: "error parsing pool ID", + setup: func() { + // Set valid params + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + }, + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "invalid_pool_id", // NaN invalid pool ID + }, + expectedError: "Error converting osmosis pool id", + }, + { + name: "error submitting ICQ request", + setup: func() { + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Mock ICQ keeper to return error + s.mockICQKeeper = MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + return fmt.Errorf("mock ICQ submit error") + }, + } + s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + }, + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + }, + expectedError: "Error submitting OsmosisClPool ICQ", + }, + { + name: "error setting query in progress", + setup: func() { + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Setup mock ICQ keeper with success response + s.mockICQKeeper = MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + // Remove token price so set query in progress will fail to get it after SubmitICQRequestFn returns + s.App.ICQOracleKeeper.RemoveTokenPrice(ctx, "uatom", "uusdc", "1") + return nil + }, + } + s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + + // Don't set the token price first, which will cause SetTokenPriceQueryInProgress to fail + }, + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + }, + expectedError: "Error updating queryInProgress=true", + }, + { + name: "successful submission", + setup: func() { + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Setup mock ICQ keeper with success response + s.mockICQKeeper = MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + return nil + }, + } + s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + }, + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + }, + expectedError: "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + // Run test case setup + tc.setup() + + // If this is not an error case testing query in progress, + // set the token price first + if tc.expectedError != "token price not found" { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tc.tokenPrice) + s.Require().NoError(err) + } + + // Execute + err := s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tc.tokenPrice) + + // Verify results + if tc.expectedError != "" { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectedError) + } else { + s.Require().NoError(err) + + // For successful case, verify query in progress was set + tokenPriceAfter, err := s.App.ICQOracleKeeper.GetTokenPrice( + s.Ctx, + tc.tokenPrice.BaseDenom, + tc.tokenPrice.QuoteDenom, + tc.tokenPrice.OsmosisPoolId, + ) + s.Require().NoError(err) + s.Require().True(tokenPriceAfter.QueryInProgress) + } + }) + } +} + +func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { + var capturedQuery icqtypes.Query + var capturedProve bool + + // Setup mock ICQ keeper to capture the submitted query and prove flag + s.mockICQKeeper = MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + capturedQuery = query + capturedProve = prove + return nil + }, + } + s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + + // Set up test parameters + tokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err) + + params := types.Params{ + OsmosisChainId: "osmosis-1", + OsmosisConnectionId: "connection-0", + IcqTimeoutSec: 60, + } + err = s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Submit ICQ request + err = s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) + s.Require().NoError(err) + + // Verify the captured query data + s.Require().NotEmpty(capturedQuery.Id, "query ID should not be empty") + expectedQueryId := fmt.Sprintf("%s|%s|%s|%d", + tokenPrice.BaseDenom, + tokenPrice.QuoteDenom, + tokenPrice.OsmosisPoolId, + s.Ctx.BlockHeight(), + ) + s.Require().Equal(expectedQueryId, capturedQuery.Id, "query ID should match expected format") + + s.Require().Equal(params.OsmosisChainId, capturedQuery.ChainId) + s.Require().Equal(params.OsmosisConnectionId, capturedQuery.ConnectionId) + s.Require().Equal(icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, capturedQuery.QueryType) + s.Require().Equal(types.ModuleName, capturedQuery.CallbackModule) + s.Require().Equal(keeper.ICQCallbackID_OsmosisClPool, capturedQuery.CallbackId) + + // Verify request data format (pool key) + osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) + s.Require().NoError(err) + expectedRequestData := icqtypes.FormatOsmosisKeyPool(osmosisPoolId) + s.Require().Equal(expectedRequestData, capturedQuery.RequestData) + + // Verify callback data contains the token price + var decodedTokenPrice types.TokenPrice + err = s.App.AppCodec().Unmarshal(capturedQuery.CallbackData, &decodedTokenPrice) + s.Require().NoError(err) + s.Require().Equal(tokenPrice.BaseDenom, decodedTokenPrice.BaseDenom) + s.Require().Equal(tokenPrice.QuoteDenom, decodedTokenPrice.QuoteDenom) + s.Require().Equal(tokenPrice.OsmosisPoolId, decodedTokenPrice.OsmosisPoolId) + + // Verify timeout settings + expectedTimeout := time.Duration(params.IcqTimeoutSec) * time.Second + s.Require().Equal(expectedTimeout, capturedQuery.TimeoutDuration) + s.Require().Equal(icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, capturedQuery.TimeoutPolicy) + + // Verify prove flag + // For Osmosis CL pool queries, we require cryptographic proofs to ensure data authenticity + s.Require().True(capturedProve, "prove flag should be true to request cryptographic proofs in ICQ response") +} diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 04242f361d..9c2f1d2aeb 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -11,15 +11,13 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - interchainquerykeeper "github.com/Stride-Labs/stride/v24/x/interchainquery/keeper" - "github.com/Stride-Labs/stride/v24/x/icqoracle/types" ) type Keeper struct { cdc codec.Codec storeKey storetypes.StoreKey - icqKeeper interchainquerykeeper.Keeper + IcqKeeper types.IcqKeeper } func NewKeeper( diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index 4934eea7be..c4929d24b4 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -3,19 +3,34 @@ package keeper_test import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" "github.com/Stride-Labs/stride/v24/app/apptesting" "github.com/Stride-Labs/stride/v24/x/icqoracle/keeper" "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" ) type KeeperTestSuite struct { apptesting.AppTestHelper + mockICQKeeper MockICQKeeper } +// Helper function to setup keeper with mock ICQ keeper +func (s *KeeperTestSuite) SetupMockICQKeeper() { + mockICQKeeper := MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + return nil + }, + } + s.App.ICQOracleKeeper.IcqKeeper = mockICQKeeper +} + +// Modify SetupTest to include mock setup func (s *KeeperTestSuite) SetupTest() { s.Setup() + s.SetupMockICQKeeper() } // Dynamically gets the MsgServer for this module's keeper diff --git a/x/icqoracle/types/expected_keepers.go b/x/icqoracle/types/expected_keepers.go index ab1254f4c2..abeafff956 100644 --- a/x/icqoracle/types/expected_keepers.go +++ b/x/icqoracle/types/expected_keepers.go @@ -1 +1,12 @@ package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/interchainquery/types" +) + +// IcqKeeper defines the expected interface needed to send ICQ requests. +type IcqKeeper interface { + SubmitICQRequest(ctx sdk.Context, query types.Query, forceUnique bool) error +} From 303eac9c85d6da46cdefc76230207167f2cb71b9 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 22 Jan 2025 19:55:05 +0200 Subject: [PATCH 074/115] test OsmosisClPoolCallback and fix icq callback wiring in app.go --- app/app.go | 6 + app/apptesting/test_helpers.go | 2 +- x/icqoracle/keeper/icq.go | 4 +- x/icqoracle/keeper/icq_test.go | 277 +++++++++++++++++++++++++++--- x/icqoracle/keeper/keeper_test.go | 8 + 5 files changed, 268 insertions(+), 29 deletions(-) diff --git a/app/app.go b/app/app.go index a7fa69bba7..9bb5d1d8a1 100644 --- a/app/app.go +++ b/app/app.go @@ -787,6 +787,12 @@ func NewStrideApp( ) icqOracleModule := icqoracle.NewAppModule(appCodec, app.ICQOracleKeeper) + // Register ICQ callbacks + err = app.InterchainqueryKeeper.SetCallbackHandler(icqoracletypes.ModuleName, app.ICQOracleKeeper.ICQCallbackHandler()) + if err != nil { + return nil + } + app.AuctionKeeper = *auctionkeeper.NewKeeper( appCodec, keys[auctiontypes.StoreKey], diff --git a/app/apptesting/test_helpers.go b/app/apptesting/test_helpers.go index 3e4ccb12df..141cc5f158 100644 --- a/app/apptesting/test_helpers.go +++ b/app/apptesting/test_helpers.go @@ -81,7 +81,7 @@ type AppTestHelper struct { // AppTestHelper Constructor func (s *AppTestHelper) Setup() { s.App = app.InitStrideTestApp(true) - s.Ctx = s.App.BaseApp.NewContext(false, tmtypesproto.Header{Height: 1, ChainID: StrideChainID}) + s.Ctx = s.App.BaseApp.NewContext(false, tmtypesproto.Header{Height: 1, ChainID: StrideChainID, Time: time.Now().UTC()}) s.QueryHelper = &baseapp.QueryServiceTestHelper{ GRPCQueryRouter: s.App.GRPCQueryRouter(), Ctx: s.Ctx, diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 9350968855..997b5ae7c8 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -126,7 +126,7 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype } // Unmarshal the query response args to determine the balance - newSpotPrice, err := unmarshalSpotPriceFromOsmosisClPool(tokenPrice, args) + newSpotPrice, err := UnmarshalSpotPriceFromOsmosisClPool(tokenPrice, args) if err != nil { return errorsmod.Wrap(err, "Error determining spot price from query response") } @@ -142,7 +142,7 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype return nil } -func unmarshalSpotPriceFromOsmosisClPool(tokenPrice types.TokenPrice, queryResponseBz []byte) (price math.LegacyDec, err error) { +func UnmarshalSpotPriceFromOsmosisClPool(tokenPrice types.TokenPrice, queryResponseBz []byte) (price math.LegacyDec, err error) { var pool deps.OsmosisConcentratedLiquidityPool if err := proto.Unmarshal(queryResponseBz, &pool); err != nil { return math.LegacyZeroDec(), err diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index f3e196a231..86ab66386f 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -28,25 +28,6 @@ func (m MockICQKeeper) SubmitICQRequest(ctx sdk.Context, query icqtypes.Query, p return nil } -// Helper function to create mock pool data -func (s *KeeperTestSuite) createMockPoolData(baseDenom string, quoteDenom string) []byte { - pool := deps.OsmosisConcentratedLiquidityPool{ - Id: 1, - CurrentTickLiquidity: math.LegacyNewDec(1000000), - Token0: baseDenom, - Token1: quoteDenom, - CurrentSqrtPrice: osmomath.NewBigDec(1000000), // This represents a price of 1.0 - CurrentTick: 0, - TickSpacing: 100, - ExponentAtPriceOne: 6, - SpreadFactor: math.LegacyNewDecWithPrec(1, 3), // 0.1% - } - - bz, err := proto.Marshal(&pool) - s.Require().NoError(err, "no error expected when marshaling mock pool data") - return bz -} - func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQUnknownPrice() { // Set up test parameters tokenPrice := types.TokenPrice{ @@ -117,13 +98,6 @@ func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { s.Require().True(tokenPriceAfter.QueryInProgress) } -func (s *KeeperTestSuite) TestICQCallbacksRegistration() { - callbacks := s.App.ICQOracleKeeper.ICQCallbackHandler().RegisterICQCallbacks() - - // Verify the expected callbacks are registered - s.Require().True(callbacks.HasICQCallback("osmosisclpool"), "osmosisclpool callback should be registered after RegisterICQCallbacks") -} - func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { testCases := []struct { name string @@ -236,6 +210,9 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { for _, tc := range testCases { s.Run(tc.name, func() { + // Reset context for each test case + s.SetupTest() + // Run test case setup tc.setup() @@ -344,3 +321,251 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { // For Osmosis CL pool queries, we require cryptographic proofs to ensure data authenticity s.Require().True(capturedProve, "prove flag should be true to request cryptographic proofs in ICQ response") } + +// Helper function to create mock pool data +func (s *KeeperTestSuite) createMockPoolData(baseDenom string, quoteDenom string) []byte { + pool := deps.OsmosisConcentratedLiquidityPool{ + Token0: baseDenom, + Token1: quoteDenom, + // The square root of the price + // For a price of 1.5, 1.224744871 is the square root + CurrentSqrtPrice: osmomath.NewBigDecWithPrec(1224744871, 9), + } + + bz, err := proto.Marshal(&pool) + s.Require().NoError(err, "no error expected when marshaling mock pool data") + return bz +} + +func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { + // Setup base test parameters used across test cases + baseTokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "ibc/uusdc", + SpotPrice: math.LegacyNewDec(2), + QueryInProgress: true, + } + + testCases := []struct { + name string + setup func() ([]byte, icqtypes.Query) + expectedError string + verify func(err error) + }{ + { + name: "invalid callback data", + setup: func() ([]byte, icqtypes.Query) { + return []byte{}, icqtypes.Query{ + CallbackData: []byte("invalid callback data"), + } + }, + expectedError: "Error deserializing query.CallbackData", + }, + { + name: "token price not found", + setup: func() ([]byte, icqtypes.Query) { + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Don't set the token price in state + return []byte{}, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "price not found", + }, + { + name: "query not in progress", + setup: func() ([]byte, icqtypes.Query) { + tokenPrice := baseTokenPrice + tokenPrice.QueryInProgress = false + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&tokenPrice) + s.Require().NoError(err) + + return []byte{}, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "", + verify: func(err error) { + s.Require().NoError(err, "no error expected when query not in progress") + }, + }, + { + name: "invalid pool data", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + return []byte("invalid pool data"), icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "Error determining spot price from query response", + }, + { + name: "successful update with valid pool data", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create mock pool data with expected price of 2.0 + poolData := s.createMockPoolData( + baseTokenPrice.OsmosisBaseDenom, + baseTokenPrice.OsmosisQuoteDenom, + ) + + return poolData, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "", + verify: func(err error) { + s.Require().NoError(err) + + // Verify token price was updated correctly + tokenPrice := s.MustGetTokenPrice( + baseTokenPrice.BaseDenom, + baseTokenPrice.QuoteDenom, + baseTokenPrice.OsmosisPoolId, + ) + + // Verify updated fields + s.Require().False(tokenPrice.QueryInProgress) + s.Require().Equal(s.Ctx.BlockTime().UnixNano(), tokenPrice.UpdatedAt.UnixNano()) + s.Require().InDelta(1.5, tokenPrice.SpotPrice.MustFloat64(), 0.01) + }, + }, + { + name: "successful update with inverse pool data", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create pool with swapped denoms + poolData := s.createMockPoolData( + baseTokenPrice.OsmosisQuoteDenom, // Swapped! + baseTokenPrice.OsmosisBaseDenom, // Swapped! + ) + + return poolData, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "", + verify: func(err error) { + s.Require().NoError(err) + + // Verify token price was updated correctly + tokenPrice := s.MustGetTokenPrice( + baseTokenPrice.BaseDenom, + baseTokenPrice.QuoteDenom, + baseTokenPrice.OsmosisPoolId, + ) + + // Verify updated fields + s.Require().False(tokenPrice.QueryInProgress) + s.Require().Equal(s.Ctx.BlockTime().UnixNano(), tokenPrice.UpdatedAt.UnixNano()) + s.Require().InDelta(1/1.5, tokenPrice.SpotPrice.MustFloat64(), 0.01) // inversed price + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + // Reset context for each test case + s.SetupTest() + + // Run test case setup + poolData, query := tc.setup() + + // Execute callback + err := s.icqCallbacks.CallICQCallback( + s.Ctx, + keeper.ICQCallbackID_OsmosisClPool, + poolData, + query, + ) + + // Verify results + if tc.expectedError != "" { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectedError) + } else if tc.verify != nil { + tc.verify(err) + } + }) + } +} + +func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { + baseTokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "uusdc", + } + + testCases := []struct { + name string + tokenPrice types.TokenPrice + poolData []byte + expectedPrice math.LegacyDec + expectedError string + }{ + { + name: "invalid pool data", + tokenPrice: baseTokenPrice, + poolData: []byte("invalid pool data"), + expectedError: "failed to unmarshal", + }, + { + name: "successful price calculation", + tokenPrice: baseTokenPrice, + poolData: s.createMockPoolData( + baseTokenPrice.OsmosisBaseDenom, + baseTokenPrice.OsmosisQuoteDenom, + ), + expectedPrice: math.LegacyNewDec(1), // Based on our mock pool data + }, + { + name: "swapped denoms", + tokenPrice: baseTokenPrice, + poolData: s.createMockPoolData( + baseTokenPrice.OsmosisQuoteDenom, // Swapped! + baseTokenPrice.OsmosisBaseDenom, // Swapped! + ), + expectedError: "denom not found in pool", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + spotPrice, err := keeper.UnmarshalSpotPriceFromOsmosisClPool(tc.tokenPrice, tc.poolData) + + if tc.expectedError != "" { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expectedError) + } else { + s.Require().NoError(err) + s.Require().True(tc.expectedPrice.Sub(spotPrice).Abs().LTE(math.LegacyNewDecWithPrec(1, 6))) + } + }) + } +} diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index c4929d24b4..52ecc935d1 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -15,6 +15,7 @@ import ( type KeeperTestSuite struct { apptesting.AppTestHelper mockICQKeeper MockICQKeeper + icqCallbacks keeper.ICQCallbacks } // Helper function to setup keeper with mock ICQ keeper @@ -31,6 +32,13 @@ func (s *KeeperTestSuite) SetupMockICQKeeper() { func (s *KeeperTestSuite) SetupTest() { s.Setup() s.SetupMockICQKeeper() + + // Register ICQ callback + s.icqCallbacks = s.App.ICQOracleKeeper.ICQCallbackHandler() + s.icqCallbacks.RegisterICQCallbacks() + + s.Require().True(s.icqCallbacks.HasICQCallback(keeper.ICQCallbackID_OsmosisClPool), + "OsmosisClPool callback should be registered") } // Dynamically gets the MsgServer for this module's keeper From 0c048330c17e4938b2f091b13f482bd12e9ff946 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 22 Jan 2025 20:02:55 +0200 Subject: [PATCH 075/115] test UnmarshalSpotPriceFromOsmosisClPool --- x/icqoracle/keeper/icq_test.go | 37 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index 86ab66386f..10ebbc92a3 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -533,25 +533,40 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { name: "invalid pool data", tokenPrice: baseTokenPrice, poolData: []byte("invalid pool data"), - expectedError: "failed to unmarshal", + expectedError: "proto: wrong wireType", }, { - name: "successful price calculation", + name: "successful price calculation - base/quote order", tokenPrice: baseTokenPrice, poolData: s.createMockPoolData( baseTokenPrice.OsmosisBaseDenom, baseTokenPrice.OsmosisQuoteDenom, ), - expectedPrice: math.LegacyNewDec(1), // Based on our mock pool data + expectedPrice: math.LegacyNewDecWithPrec(15, 1), // 1.5 from mock pool data }, { - name: "swapped denoms", + name: "successful price calculation - quote/base order", tokenPrice: baseTokenPrice, poolData: s.createMockPoolData( - baseTokenPrice.OsmosisQuoteDenom, // Swapped! - baseTokenPrice.OsmosisBaseDenom, // Swapped! + baseTokenPrice.OsmosisQuoteDenom, + baseTokenPrice.OsmosisBaseDenom, ), - expectedError: "denom not found in pool", + expectedPrice: math.LegacyMustNewDecFromStr("0.666666666666666667"), // 1/1.5 from mock pool data + }, + { + name: "different denom ordering in pool", + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "different_denom", // Different from pool data + }, + poolData: s.createMockPoolData( + "ibc/uatom", + "uusdc", + ), + expectedError: "quote asset denom (different_denom) is not in pool with (ibc/uatom, uusdc) pair", }, } @@ -564,7 +579,13 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { s.Require().Contains(err.Error(), tc.expectedError) } else { s.Require().NoError(err) - s.Require().True(tc.expectedPrice.Sub(spotPrice).Abs().LTE(math.LegacyNewDecWithPrec(1, 6))) + // Use InDelta for floating point comparison with small tolerance + s.Require().InDelta( + tc.expectedPrice.MustFloat64(), + spotPrice.MustFloat64(), + 0.01, + "expected price %v, got %v", tc.expectedPrice, spotPrice, + ) } }) } From 14c819a8607ebf08a08f901f572e839ae1fea941 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 22 Jan 2025 20:20:44 +0200 Subject: [PATCH 076/115] icqoracle: add more test cases and fix handling a pool with zero price --- .../osmosis_concentrated_liquidity_pool.go | 3 + x/icqoracle/keeper/icq_test.go | 177 ++++++++++++++++++ 2 files changed, 180 insertions(+) diff --git a/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go b/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go index a6a178466e..e3f05c3f21 100644 --- a/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go +++ b/x/icqoracle/deps/types/osmosis_concentrated_liquidity_pool.go @@ -24,6 +24,9 @@ func (p OsmosisConcentratedLiquidityPool) SpotPrice(quoteAssetDenom string, base if quoteAssetDenom != p.Token0 && quoteAssetDenom != p.Token1 { return math.LegacyDec{}, fmt.Errorf("quote asset denom (%s) is not in pool with (%s, %s) pair", quoteAssetDenom, p.Token0, p.Token1) } + if p.CurrentSqrtPrice.IsZero() { + return math.LegacyDec{}, fmt.Errorf("zero sqrt price would result in either a zero spot price or division by zero when calculating the inverse price") + } priceSquared := p.CurrentSqrtPrice.PowerInteger(2) // The reason why we convert the result to Dec and then back to BigDec is to temporarily diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index 10ebbc92a3..b954ca1609 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -484,6 +484,183 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { s.Require().InDelta(1/1.5, tokenPrice.SpotPrice.MustFloat64(), 0.01) // inversed price }, }, + { + name: "empty query callback data", + setup: func() ([]byte, icqtypes.Query) { + return []byte{}, icqtypes.Query{ + CallbackData: []byte{}, + } + }, + expectedError: "price not found for baseDenom='' quoteDenom='' poolId=''", + }, + { + name: "nil query callback data", + setup: func() ([]byte, icqtypes.Query) { + return []byte{}, icqtypes.Query{ + CallbackData: nil, + } + }, + expectedError: "price not found for baseDenom='' quoteDenom='' poolId=''", + }, + { + name: "corrupted token price in callback data", + setup: func() ([]byte, icqtypes.Query) { + // Create corrupted protobuf data + corruptedData := []byte{0xFF, 0xFF, 0xFF, 0xFF} + return []byte{}, icqtypes.Query{ + CallbackData: corruptedData, + } + }, + expectedError: "Error deserializing query.CallbackData", + }, + { + name: "empty pool response data", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + return []byte{}, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "Error determining spot price from query response", + }, + { + name: "nil pool response data", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + return nil, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "Error determining spot price from query response", + }, + { + name: "corrupted pool response data", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create corrupted protobuf data + corruptedPoolData := []byte{0xFF, 0xFF, 0xFF, 0xFF} + return corruptedPoolData, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "Error determining spot price from query response", + }, + { + name: "pool with empty tokens", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create pool with empty token denoms + pool := deps.OsmosisConcentratedLiquidityPool{ + Token0: "", + Token1: "", + CurrentSqrtPrice: osmomath.NewBigDecWithPrec(1224744871, 9), + } + poolBz, err := proto.Marshal(&pool) + s.Require().NoError(err) + + return poolBz, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "Error determining spot price from query response", + }, + { + name: "pool with invalid sqrt price", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create pool with invalid sqrt price + pool := deps.OsmosisConcentratedLiquidityPool{ + Token0: baseTokenPrice.OsmosisBaseDenom, + Token1: baseTokenPrice.OsmosisQuoteDenom, + CurrentSqrtPrice: osmomath.NewBigDec(0), // Invalid sqrt price of 0 + } + poolBz, err := proto.Marshal(&pool) + s.Require().NoError(err) + + return poolBz, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "zero sqrt price", + }, + { + name: "pool with invalid inverse sqrt price", + setup: func() ([]byte, icqtypes.Query) { + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create pool with invalid sqrt price + pool := deps.OsmosisConcentratedLiquidityPool{ + Token0: baseTokenPrice.OsmosisQuoteDenom, + Token1: baseTokenPrice.OsmosisBaseDenom, + CurrentSqrtPrice: osmomath.NewBigDec(0), // Invalid sqrt price of 0 + } + poolBz, err := proto.Marshal(&pool) + s.Require().NoError(err) + + return poolBz, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: "zero sqrt price", + }, + { + name: "error setting updated token price", + setup: func() ([]byte, icqtypes.Query) { + // First set the token price + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) + s.Require().NoError(err) + + tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) + s.Require().NoError(err) + + // Create valid pool data + poolData := s.createMockPoolData( + baseTokenPrice.OsmosisBaseDenom, + baseTokenPrice.OsmosisQuoteDenom, + ) + + // Remove the token price from state right before setting the updated price + s.App.ICQOracleKeeper.RemoveTokenPrice(s.Ctx, baseTokenPrice.BaseDenom, baseTokenPrice.QuoteDenom, baseTokenPrice.OsmosisPoolId) + + return poolData, icqtypes.Query{ + CallbackData: tokenPriceBz, + } + }, + expectedError: fmt.Sprintf( + "price not found for baseDenom='%s' quoteDenom='%s' poolId='%s'", + baseTokenPrice.BaseDenom, + baseTokenPrice.QuoteDenom, + baseTokenPrice.OsmosisPoolId), + }, } for _, tc := range testCases { From 8261e1041d316b7bff37eb341f91440252a5c303 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 18:14:44 +0200 Subject: [PATCH 077/115] icqoracle: test BeginBlocker and skip token price updates if query is already in progress --- x/icqoracle/keeper/abci.go | 7 +- x/icqoracle/keeper/abci_test.go | 274 ++++++++++++++++++++++++++ x/icqoracle/keeper/icq_test.go | 24 +-- x/icqoracle/keeper/keeper.go | 5 + x/icqoracle/keeper/keeper_test.go | 16 +- x/icqoracle/types/expected_keepers.go | 2 +- 6 files changed, 309 insertions(+), 19 deletions(-) create mode 100644 x/icqoracle/keeper/abci_test.go diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index 8f6dd6eec6..d21d0c3bb3 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -24,8 +24,13 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { // Get last update time for this token lastUpdate := tokenPrice.UpdatedAt + // Skip if there's already a query in progress + if tokenPrice.QueryInProgress { + continue + } + // If never updated or update interval has passed - if lastUpdate.IsZero() || !tokenPrice.QueryInProgress && currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) { + if lastUpdate.IsZero() || currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) { // Update price for this specific token err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice) if err != nil { diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go new file mode 100644 index 0000000000..6324f2a0c1 --- /dev/null +++ b/x/icqoracle/keeper/abci_test.go @@ -0,0 +1,274 @@ +package keeper_test + +import ( + "strings" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/icqoracle/types" + icqtypes "github.com/Stride-Labs/stride/v24/x/interchainquery/types" +) + +func (s *KeeperTestSuite) TestBeginBlockerParams() { + // Delete params from store + s.DeleteParams() + + // Run BeginBlocker with missing params + s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) + + // Get the logged output + logOutput := s.logBuffer.String() + + // Verify the error was logged + s.Require().True( + strings.Contains(logOutput, "failed to get icqoracle params"), + "expected error log message about missing params, got: %s", logOutput, + ) +} + +func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { + var submitICQCalled bool + + // Mock ICQ keeper to capture submitted queries + mockICQKeeper := MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { + submitICQCalled = true + return nil + }, + } + + params := types.Params{ + UpdateIntervalSec: 60, // 1 minute interval + IcqTimeoutSec: 30, + } + + now := time.Now().UTC() + staleTime := now.Add(-2 * time.Minute) // Older than update interval + freshTime := now.Add(-30 * time.Second) // More recent than update interval + + testCases := []struct { + name string + tokenPrice types.TokenPrice + expectedICQSubmit bool + }{ + { + name: "never updated token price", + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + UpdatedAt: time.Time{}, // Zero time + }, + expectedICQSubmit: true, + }, + { + name: "stale token price", + tokenPrice: types.TokenPrice{ + BaseDenom: "uosmo", + QuoteDenom: "uusdc", + OsmosisPoolId: "2", + UpdatedAt: staleTime, + }, + expectedICQSubmit: true, + }, + { + name: "fresh token price", + tokenPrice: types.TokenPrice{ + BaseDenom: "ustrd", + QuoteDenom: "uusdc", + OsmosisPoolId: "3", + UpdatedAt: freshTime, + }, + expectedICQSubmit: false, + }, + { + name: "query in progress stale token price", + tokenPrice: types.TokenPrice{ + BaseDenom: "ujuno", + QuoteDenom: "uusdc", + OsmosisPoolId: "4", + UpdatedAt: staleTime, + QueryInProgress: true, + }, + expectedICQSubmit: false, + }, + { + name: "query in progress fresh token price", + tokenPrice: types.TokenPrice{ + BaseDenom: "udydx", + QuoteDenom: "uusdc", + OsmosisPoolId: "5", + UpdatedAt: freshTime, + QueryInProgress: true, + }, + expectedICQSubmit: false, + }, + { + name: "query in progress never updated token price", + tokenPrice: types.TokenPrice{ + BaseDenom: "utia", + QuoteDenom: "uusdc", + OsmosisPoolId: "6", + UpdatedAt: time.Time{}, // Zero time + QueryInProgress: true, + }, + expectedICQSubmit: false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + // Reset test state + s.SetupTest() + + // Setup params + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Reset mock IcqKeeper + s.App.ICQOracleKeeper.IcqKeeper = mockICQKeeper + submitICQCalled = false + + // Store token price + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tc.tokenPrice) + s.Require().NoError(err) + + // Set block time to now + s.Ctx = s.Ctx.WithBlockTime(now) + + // Run BeginBlocker + s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) + + // Verify if ICQ was submitted as expected + s.Require().Equal(tc.expectedICQSubmit, submitICQCalled, + "ICQ submission status does not match expected for case: %s", tc.name) + + // If ICQ was expected to be submitted, verify the token price query in progress flag + if tc.expectedICQSubmit { + updatedPrice := s.MustGetTokenPrice( + tc.tokenPrice.BaseDenom, + tc.tokenPrice.QuoteDenom, + tc.tokenPrice.OsmosisPoolId, + ) + s.Require().True(updatedPrice.QueryInProgress, + "query in progress should be true after BeginBlocker for case: %s", tc.name) + } + }) + } +} + +// func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { +// // Setup mock ICQ keeper that returns an error +// s.mockICQKeeper = MockICQKeeper{ +// SubmitICQRequest: func(ctx sdk.Context, query types.Query, forceUnique bool) error { +// return types.ErrICQSubmitFailed +// }, +// } +// s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + +// // Set params +// params := types.Params{ +// UpdateIntervalSec: 60, +// IcqTimeoutSec: 30, +// } +// err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) +// s.Require().NoError(err) + +// // Create token price that needs updating +// tokenPrice := types.TokenPrice{ +// BaseDenom: "uatom", +// QuoteDenom: "uusdc", +// OsmosisPoolId: "1", +// UpdatedAt: time.Time{}, // Zero time to trigger update +// } +// err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) +// s.Require().NoError(err) + +// // Run BeginBlocker - should log error but continue +// s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) + +// // Verify token price was not modified +// updatedPrice := s.MustGetTokenPrice( +// tokenPrice.BaseDenom, +// tokenPrice.QuoteDenom, +// tokenPrice.OsmosisPoolId, +// ) +// s.Require().False(updatedPrice.QueryInProgress, +// "query in progress should remain false when ICQ submission fails") +// } + +// func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { +// var submittedQueries int + +// // Setup mock ICQ keeper to count submitted queries +// s.mockICQKeeper = MockICQKeeper{ +// SubmitICQRequest: func(ctx sdk.Context, query types.Query, forceUnique bool) error { +// submittedQueries++ +// return nil +// }, +// } +// s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper + +// // Set params +// params := types.Params{ +// UpdateIntervalSec: 60, +// IcqTimeoutSec: 30, +// } +// err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) +// s.Require().NoError(err) + +// now := time.Now().UTC() +// oldTime := now.Add(-2 * time.Minute) + +// // Create multiple token prices +// tokenPrices := []types.TokenPrice{ +// { +// BaseDenom: "uatom", +// QuoteDenom: "uusdc", +// OsmosisPoolId: "1", +// UpdatedAt: oldTime, +// }, +// { +// BaseDenom: "uosmo", +// QuoteDenom: "uusdc", +// OsmosisPoolId: "2", +// UpdatedAt: oldTime, +// }, +// { +// BaseDenom: "ustrd", +// QuoteDenom: "uusdc", +// OsmosisPoolId: "3", +// UpdatedAt: oldTime, +// QueryInProgress: true, // Should skip this one +// }, +// } + +// // Store all token prices +// for _, tp := range tokenPrices { +// err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tp) +// s.Require().NoError(err) +// } + +// // Set block time +// s.Ctx = s.Ctx.WithBlockTime(now) + +// // Run BeginBlocker +// s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) + +// // Verify number of submitted queries +// s.Require().Equal(2, submittedQueries, +// "expected 2 ICQ queries to be submitted (skipping the one in progress)") + +// // Verify query in progress flags +// for _, tp := range tokenPrices { +// updatedPrice := s.MustGetTokenPrice(tp.BaseDenom, tp.QuoteDenom, tp.OsmosisPoolId) +// if tp.QueryInProgress { +// s.Require().True(updatedPrice.QueryInProgress, +// "query in progress should remain true for token that was already updating") +// } else { +// s.Require().True(updatedPrice.QueryInProgress, +// "query in progress should be true for tokens that needed updates") +// } +// } +// } diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index b954ca1609..e0ee4ac69a 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -18,12 +18,12 @@ import ( // Mock ICQ Keeper struct type MockICQKeeper struct { - SubmitICQRequestFn func(ctx sdk.Context, query icqtypes.Query, prove bool) error + SubmitICQRequestFn func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error } -func (m MockICQKeeper) SubmitICQRequest(ctx sdk.Context, query icqtypes.Query, prove bool) error { +func (m MockICQKeeper) SubmitICQRequest(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { if m.SubmitICQRequestFn != nil { - return m.SubmitICQRequestFn(ctx, query, prove) + return m.SubmitICQRequestFn(ctx, query, forceUnique) } return nil } @@ -54,7 +54,7 @@ func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { // Setup mock ICQ keeper with custom behavior s.mockICQKeeper = MockICQKeeper{ - SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { submittedQuery = query return nil }, @@ -137,7 +137,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { // Mock ICQ keeper to return error s.mockICQKeeper = MockICQKeeper{ - SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { return fmt.Errorf("mock ICQ submit error") }, } @@ -163,8 +163,8 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { // Setup mock ICQ keeper with success response s.mockICQKeeper = MockICQKeeper{ - SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { - // Remove token price so set query in progress will fail to get it after SubmitICQRequestFn returns + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { + // Remove token price so set query in progress will fail to get it after SubmitICQRequest returns s.App.ICQOracleKeeper.RemoveTokenPrice(ctx, "uatom", "uusdc", "1") return nil }, @@ -193,7 +193,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { // Setup mock ICQ keeper with success response s.mockICQKeeper = MockICQKeeper{ - SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { return nil }, } @@ -249,13 +249,11 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { var capturedQuery icqtypes.Query - var capturedProve bool // Setup mock ICQ keeper to capture the submitted query and prove flag s.mockICQKeeper = MockICQKeeper{ - SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { capturedQuery = query - capturedProve = prove return nil }, } @@ -316,10 +314,6 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { expectedTimeout := time.Duration(params.IcqTimeoutSec) * time.Second s.Require().Equal(expectedTimeout, capturedQuery.TimeoutDuration) s.Require().Equal(icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, capturedQuery.TimeoutPolicy) - - // Verify prove flag - // For Osmosis CL pool queries, we require cryptographic proofs to ensure data authenticity - s.Require().True(capturedProve, "prove flag should be true to request cryptographic proofs in ICQ response") } // Helper function to create mock pool data diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 9c2f1d2aeb..65770e927c 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -235,3 +235,8 @@ func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { return prices } + +// GetStoreKey returns the store key +func (k Keeper) GetStoreKey() storetypes.StoreKey { + return k.storeKey +} diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index 52ecc935d1..824fa7c831 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -1,8 +1,10 @@ package keeper_test import ( + "bytes" "testing" + "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" @@ -14,14 +16,15 @@ import ( type KeeperTestSuite struct { apptesting.AppTestHelper - mockICQKeeper MockICQKeeper + mockICQKeeper types.IcqKeeper icqCallbacks keeper.ICQCallbacks + logBuffer bytes.Buffer } // Helper function to setup keeper with mock ICQ keeper func (s *KeeperTestSuite) SetupMockICQKeeper() { mockICQKeeper := MockICQKeeper{ - SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, prove bool) error { + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { return nil }, } @@ -39,6 +42,10 @@ func (s *KeeperTestSuite) SetupTest() { s.Require().True(s.icqCallbacks.HasICQCallback(keeper.ICQCallbackID_OsmosisClPool), "OsmosisClPool callback should be registered") + + // Create a logger with accessible output + logger := log.NewTMLogger(&s.logBuffer) + s.Ctx = s.Ctx.WithLogger(logger) } // Dynamically gets the MsgServer for this module's keeper @@ -60,3 +67,8 @@ func (s *KeeperTestSuite) MustGetTokenPrice(baseDenom string, quoteDenom string, s.Require().NoError(err, "no error expected when getting token price") return tp } + +func (s *KeeperTestSuite) DeleteParams() { + store := s.Ctx.KVStore(s.App.ICQOracleKeeper.GetStoreKey()) + store.Delete([]byte(types.ParamsKey)) +} diff --git a/x/icqoracle/types/expected_keepers.go b/x/icqoracle/types/expected_keepers.go index abeafff956..230f75a6f1 100644 --- a/x/icqoracle/types/expected_keepers.go +++ b/x/icqoracle/types/expected_keepers.go @@ -8,5 +8,5 @@ import ( // IcqKeeper defines the expected interface needed to send ICQ requests. type IcqKeeper interface { - SubmitICQRequest(ctx sdk.Context, query types.Query, forceUnique bool) error + SubmitICQRequest(ctx sdk.Context, icqtypes types.Query, forceUnique bool) error } From 2bf44300bc93f594e5e30cd18575fc8eb52305b1 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 18:17:43 +0200 Subject: [PATCH 078/115] icqoracle: TestBeginBlockerICQErrors --- x/icqoracle/keeper/abci_test.go | 78 ++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go index 6324f2a0c1..2d9cecb525 100644 --- a/x/icqoracle/keeper/abci_test.go +++ b/x/icqoracle/keeper/abci_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "strings" "time" @@ -158,45 +159,52 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { } } -// func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { -// // Setup mock ICQ keeper that returns an error -// s.mockICQKeeper = MockICQKeeper{ -// SubmitICQRequest: func(ctx sdk.Context, query types.Query, forceUnique bool) error { -// return types.ErrICQSubmitFailed -// }, -// } -// s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper +func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { + // Setup mock ICQ keeper that returns an error + s.mockICQKeeper = MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { + return fmt.Errorf("icq submit failed") + }, + } + s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper -// // Set params -// params := types.Params{ -// UpdateIntervalSec: 60, -// IcqTimeoutSec: 30, -// } -// err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) -// s.Require().NoError(err) + // Set params + params := types.Params{ + UpdateIntervalSec: 60, + IcqTimeoutSec: 30, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Create token price that needs updating + tokenPrice := types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + UpdatedAt: time.Time{}, // Zero time to trigger update + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err) -// // Create token price that needs updating -// tokenPrice := types.TokenPrice{ -// BaseDenom: "uatom", -// QuoteDenom: "uusdc", -// OsmosisPoolId: "1", -// UpdatedAt: time.Time{}, // Zero time to trigger update -// } -// err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) -// s.Require().NoError(err) + // Run BeginBlocker - should log error but continue + s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) -// // Run BeginBlocker - should log error but continue -// s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) + // Get the logged output and verify error was logged + logOutput := s.logBuffer.String() + s.Require().True( + strings.Contains(logOutput, "icq submit failed"), + "expected error log message about ICQ submission failure, got: %s", logOutput, + ) -// // Verify token price was not modified -// updatedPrice := s.MustGetTokenPrice( -// tokenPrice.BaseDenom, -// tokenPrice.QuoteDenom, -// tokenPrice.OsmosisPoolId, -// ) -// s.Require().False(updatedPrice.QueryInProgress, -// "query in progress should remain false when ICQ submission fails") -// } + // Verify token price was not modified + updatedPrice := s.MustGetTokenPrice( + tokenPrice.BaseDenom, + tokenPrice.QuoteDenom, + tokenPrice.OsmosisPoolId, + ) + s.Require().False(updatedPrice.QueryInProgress, + "query in progress should remain false when ICQ submission fails") +} // func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { // var submittedQueries int From dec54ac6c1442a691fab55a2d889e01cbc112007 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 20:06:59 +0200 Subject: [PATCH 079/115] icqoracle TestBeginBlockerMultipleTokens --- x/icqoracle/keeper/abci_test.go | 148 ++++++++++++++++---------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go index 2d9cecb525..cd7c3a6cd4 100644 --- a/x/icqoracle/keeper/abci_test.go +++ b/x/icqoracle/keeper/abci_test.go @@ -206,77 +206,77 @@ func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { "query in progress should remain false when ICQ submission fails") } -// func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { -// var submittedQueries int - -// // Setup mock ICQ keeper to count submitted queries -// s.mockICQKeeper = MockICQKeeper{ -// SubmitICQRequest: func(ctx sdk.Context, query types.Query, forceUnique bool) error { -// submittedQueries++ -// return nil -// }, -// } -// s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper - -// // Set params -// params := types.Params{ -// UpdateIntervalSec: 60, -// IcqTimeoutSec: 30, -// } -// err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) -// s.Require().NoError(err) - -// now := time.Now().UTC() -// oldTime := now.Add(-2 * time.Minute) - -// // Create multiple token prices -// tokenPrices := []types.TokenPrice{ -// { -// BaseDenom: "uatom", -// QuoteDenom: "uusdc", -// OsmosisPoolId: "1", -// UpdatedAt: oldTime, -// }, -// { -// BaseDenom: "uosmo", -// QuoteDenom: "uusdc", -// OsmosisPoolId: "2", -// UpdatedAt: oldTime, -// }, -// { -// BaseDenom: "ustrd", -// QuoteDenom: "uusdc", -// OsmosisPoolId: "3", -// UpdatedAt: oldTime, -// QueryInProgress: true, // Should skip this one -// }, -// } - -// // Store all token prices -// for _, tp := range tokenPrices { -// err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tp) -// s.Require().NoError(err) -// } - -// // Set block time -// s.Ctx = s.Ctx.WithBlockTime(now) - -// // Run BeginBlocker -// s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) - -// // Verify number of submitted queries -// s.Require().Equal(2, submittedQueries, -// "expected 2 ICQ queries to be submitted (skipping the one in progress)") - -// // Verify query in progress flags -// for _, tp := range tokenPrices { -// updatedPrice := s.MustGetTokenPrice(tp.BaseDenom, tp.QuoteDenom, tp.OsmosisPoolId) -// if tp.QueryInProgress { -// s.Require().True(updatedPrice.QueryInProgress, -// "query in progress should remain true for token that was already updating") -// } else { -// s.Require().True(updatedPrice.QueryInProgress, -// "query in progress should be true for tokens that needed updates") -// } -// } -// } +func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { + var submittedQueries int + + // Setup mock ICQ keeper to count submitted queries + mockICQKeeper := MockICQKeeper{ + SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { + submittedQueries++ + return nil + }, + } + s.App.ICQOracleKeeper.IcqKeeper = mockICQKeeper + + // Set params + params := types.Params{ + UpdateIntervalSec: 60, + IcqTimeoutSec: 30, + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + now := time.Now().UTC() + staleTime := now.Add(-2 * time.Minute) + + // Create multiple token prices + tokenPrices := []types.TokenPrice{ + { + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + UpdatedAt: staleTime, + }, + { + BaseDenom: "uosmo", + QuoteDenom: "uusdc", + OsmosisPoolId: "2", + UpdatedAt: staleTime, + }, + { + BaseDenom: "ustrd", + QuoteDenom: "uusdc", + OsmosisPoolId: "3", + UpdatedAt: staleTime, + QueryInProgress: true, // Should skip this one + }, + } + + // Store all token prices + for _, tp := range tokenPrices { + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tp) + s.Require().NoError(err) + } + + // Set block time + s.Ctx = s.Ctx.WithBlockTime(now) + + // Run BeginBlocker + s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) + + // Verify number of submitted queries + s.Require().Equal(2, submittedQueries, + "expected 2 ICQ queries to be submitted (skipping the one in progress)") + + // Verify query in progress flags + for _, tp := range tokenPrices { + updatedPrice := s.MustGetTokenPrice(tp.BaseDenom, tp.QuoteDenom, tp.OsmosisPoolId) + if tp.QueryInProgress { + s.Require().True(updatedPrice.QueryInProgress, + "query in progress should remain true for token that was already updating") + } else { + s.Require().True(updatedPrice.QueryInProgress, + "query in progress should be true for tokens that needed updates") + } + } +} From b54781e717c91b6e07155e65db9078fb3e8eb1ea Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 20:46:05 +0200 Subject: [PATCH 080/115] fix tests --- x/icqoracle/keeper/query_test.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index 9db7ec4a3d..e3ea710eca 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -97,6 +97,12 @@ func (s *KeeperTestSuite) TestQueryParams() { } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { + // Setup params + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ + PriceExpirationTimeoutSec: 60, + }) + s.Require().NoError(err, "no error expected when setting params") + // Create token price with same quote denom baseDenom := "uatom" quoteDenom := "uusdc" @@ -107,8 +113,9 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { QuoteDenom: quoteDenom, OsmosisPoolId: "1", SpotPrice: expectedPrice, + UpdatedAt: s.Ctx.BlockTime(), } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice) // Query for token price using quote denom @@ -134,6 +141,11 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ + PriceExpirationTimeoutSec: 60, + }) + s.Require().NoError(err, "no error expected when setting params") + // Create two token prices with same quote denom baseDenom1 := "uatom" baseDenom2 := "uosmo" @@ -147,8 +159,9 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { QuoteDenom: quoteDenom, OsmosisPoolId: "1", SpotPrice: expectedPrice1, + UpdatedAt: s.Ctx.BlockTime(), } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice1) // Set uosmo price @@ -157,6 +170,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { QuoteDenom: quoteDenom, OsmosisPoolId: "2", SpotPrice: expectedPrice2, + UpdatedAt: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice2) @@ -189,7 +203,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { QuoteDenom: quoteDenom, OsmosisPoolId: "1", SpotPrice: expectedPrice, - UpdatedAt: s.Ctx.BlockTime(), // Current time + UpdatedAt: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err) From be7492d6ca8a9b516b4cc2622ec12eda34c2daf8 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 21:11:05 +0200 Subject: [PATCH 081/115] test more edge cases of GetTokenPriceForQuoteDenom and improve error handling --- x/icqoracle/keeper/keeper.go | 5 ++- x/icqoracle/keeper/query_test.go | 76 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 65770e927c..43aef6f829 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -141,7 +141,7 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", baseDenom, err) } if len(baseTokenPrices) == 0 { - return math.LegacyDec{}, fmt.Errorf("no price for '%s'", baseDenom) + return math.LegacyDec{}, fmt.Errorf("no price for baseDenom '%s'", baseDenom) } // Get price expiration timeout @@ -166,6 +166,9 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu if err != nil { return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", quoteDenom, err) } + if len(quoteTokenPrices) == 0 { + return math.LegacyDec{}, fmt.Errorf("no price for quoteDenom '%s' (foundAlreadyHasStalePrice='%v')", quoteDenom, foundAlreadyHasStalePrice) + } // Init price price = math.LegacyZeroDec() diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index e3ea710eca..ad56dbecb6 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -38,6 +38,15 @@ func (s *KeeperTestSuite) TestQueryTokenPrice() { // Query with invalid request _, err = s.App.ICQOracleKeeper.TokenPrice(sdk.WrapSDKContext(s.Ctx), nil) s.Require().Error(err, "error expected when querying with nil request") + + // Query with non existing + req = &types.QueryTokenPriceRequest{ + BaseDenom: "banana", + QuoteDenom: "papaya", + PoolId: "1", + } + _, err = s.App.ICQOracleKeeper.TokenPrice(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "error expected when querying non existing token price") } func (s *KeeperTestSuite) TestQueryTokenPrices() { @@ -96,6 +105,16 @@ func (s *KeeperTestSuite) TestQueryParams() { s.Require().Error(err, "error expected when querying with nil request") } +func (s *KeeperTestSuite) TestQueryParamsError() { + s.DeleteParams() + + // Query parameters + req := &types.QueryParamsRequest{} + _, err := s.App.ICQOracleKeeper.Params(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "error expected when querying params") + s.Require().Contains(err.Error(), "EOF") +} + func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { // Setup params err := s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ @@ -295,3 +314,60 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { s.Require().Error(err, "expected error when no common quote denom exists") s.Require().Contains(err.Error(), "could not calculate price", "error should indicate price calculation failure") } + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomParamsError() { + s.DeleteParams() + + baseDenom := "uatom" + + // Set base token price with one quote denom + tokenPrice1 := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: "quote1", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err) + + // Query for token price using quote denom + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: "banana", + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "error expected when querying token price for quote denom") + s.Require().Contains(err.Error(), "error getting params") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoBaseDenom() { + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: "banana", + QuoteDenom: "papaya", + } + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "error expected when querying token price for quote denom") + s.Require().Contains(err.Error(), "no price for baseDenom 'banana'") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoQuoteDenom() { + // Set base token price with one quote denom + tokenPrice1 := types.TokenPrice{ + BaseDenom: "banana", + QuoteDenom: "quote1", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err) + + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: "banana", + QuoteDenom: "papaya", + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "error expected when querying token price for quote denom") + s.Require().Contains(err.Error(), "no price for quoteDenom 'papaya'") +} From a288831e351f034eacd48c2220f3dbbb8f774b80 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 21:21:09 +0200 Subject: [PATCH 082/115] test more edge cases of GetTokenPriceForQuoteDenom --- x/icqoracle/keeper/query_test.go | 90 ++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index ad56dbecb6..186d69d6f3 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -371,3 +371,93 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoQuoteDenom() { s.Require().Error(err, "error expected when querying token price for quote denom") s.Require().Contains(err.Error(), "no price for quoteDenom 'papaya'") } + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { + // Set up parameters with short expiration time + params := types.Params{ + PriceExpirationTimeoutSec: 60, // 1 minute timeout + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Create token prices with same quote denom + baseDenom := "uatom" + quoteDenom := "uusdc" + intermediateQuote := "uosmo" + + // Set base token price (will become stale) + tokenPrice1 := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + UpdatedAt: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err) + + // Set quote token price (fresh) + tokenPrice2 := types.TokenPrice{ + BaseDenom: quoteDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) + s.Require().NoError(err) + + // Query should fail due to stale base price + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "expected error for stale base price") + s.Require().Contains(err.Error(), "foundBaseTokenStalePrice='true'", "error should indicate base token price is stale") +} + +func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { + // Set up parameters with short expiration time + params := types.Params{ + PriceExpirationTimeoutSec: 60, // 1 minute timeout + } + err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) + s.Require().NoError(err) + + // Create token prices with same quote denom + baseDenom := "uatom" + quoteDenom := "uusdc" + intermediateQuote := "uosmo" + + // Set base token price (fresh) + tokenPrice1 := types.TokenPrice{ + BaseDenom: baseDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + UpdatedAt: s.Ctx.BlockTime(), + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) + s.Require().NoError(err) + + // Set quote token price (will be stale) + tokenPrice2 := types.TokenPrice{ + BaseDenom: quoteDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + UpdatedAt: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) + s.Require().NoError(err) + + // Query should fail due to stale quote price + req := &types.QueryTokenPriceForQuoteDenomRequest{ + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + } + _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().Error(err, "expected error for stale quote price") + s.Require().Contains(err.Error(), "foundQuoteTokenStalePrice='true'", "error should indicate quote token price is stale") +} From 96e93db5a03d01c6e72113b0fcea4b514f22f3cd Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 23 Jan 2025 23:12:44 +0200 Subject: [PATCH 083/115] auction: write a bunch of tests and improve error handling - Enhance error messages with better context using errorsmod - Fixe typos in error message strings - Remove unused Logger function - Add GetStoreKey accessor method --- x/auction/keeper/auction_type.go | 9 +- x/auction/keeper/keeper.go | 10 +- x/auction/keeper/keeper_test.go | 52 +++++ x/auction/keeper/msg_server_test.go | 321 ++++++++++++++++++++++++++++ 4 files changed, 383 insertions(+), 9 deletions(-) create mode 100644 x/auction/keeper/keeper_test.go create mode 100644 x/auction/keeper/msg_server_test.go diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index 65e4bb76e9..ffeb3f5545 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Stride-Labs/stride/v24/x/auction/types" @@ -23,9 +24,9 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type balance := k.bankKeeper.GetBalance(ctx, moduleAddr, auction.SellingDenom) sellingAmountAvailable := balance.Amount - // Verify auction has enough sellingtokens to service the bid + // Verify auction has enough selling tokens to service the bid if bid.SellingTokenAmount.GT(sellingAmountAvailable) { - return fmt.Errorf("bid wants to buy %s%s but auction has only %s%s", + return fmt.Errorf("bid wants to buy %s%s but auction only has %s%s", bid.SellingTokenAmount.String(), auction.SellingDenom, sellingAmountAvailable.String(), @@ -37,7 +38,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type // Any calculation down the road makes sense only if price is multiplied by a derivative of SellingToken price, err := k.icqoracleKeeper.GetTokenPriceForQuoteDenom(ctx, auction.SellingDenom, auction.PaymentDenom) if err != nil { - return err + return errorsmod.Wrapf(err, "error getting price for baseDenom='%s' quoteDenom='%s'", auction.SellingDenom, auction.PaymentDenom) } // Apply MinPriceMultiplier @@ -97,7 +98,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type err = k.SetAuction(ctx, auction) if err != nil { - return fmt.Errorf("failed to update auction stats") + return errorsmod.Wrap(err, "failed to update auction stats") } ctx.EventManager().EmitEvent( diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 5cc28af10f..d6a9486597 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -3,7 +3,6 @@ package keeper import ( "fmt" - "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/codec" @@ -37,10 +36,6 @@ func NewKeeper( } } -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} - // SetAuction stores auction info for a token func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) @@ -106,3 +101,8 @@ func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { // Call the handler return auctionBidHandler(ctx, k, auction, bid) } + +// GetStoreKey returns the store key +func (k Keeper) GetStoreKey() storetypes.StoreKey { + return k.storeKey +} diff --git a/x/auction/keeper/keeper_test.go b/x/auction/keeper/keeper_test.go new file mode 100644 index 0000000000..36705f24cf --- /dev/null +++ b/x/auction/keeper/keeper_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "bytes" + "testing" + + "github.com/cometbft/cometbft/libs/log" + "github.com/stretchr/testify/suite" + + "github.com/Stride-Labs/stride/v24/app/apptesting" + "github.com/Stride-Labs/stride/v24/x/auction/keeper" + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +type KeeperTestSuite struct { + apptesting.AppTestHelper + logBuffer bytes.Buffer +} + +// Modify SetupTest to include mock setup +func (s *KeeperTestSuite) SetupTest() { + s.Setup() + + // Create a logger with accessible output + logger := log.NewTMLogger(&s.logBuffer) + s.Ctx = s.Ctx.WithLogger(logger) +} + +// Dynamically gets the MsgServer for this module's keeper +// this function must be used so that the MsgServer is always created with the most updated App context +// +// which can change depending on the type of test +// (e.g. tests with only one Stride chain vs tests with multiple chains and IBC support) +func (s *KeeperTestSuite) GetMsgServer() types.MsgServer { + return keeper.NewMsgServerImpl(s.App.AuctionKeeper) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +// Helper function to get a auction and confirm there's no error +func (s *KeeperTestSuite) MustGetAuction(name string) types.Auction { + auction, err := s.App.AuctionKeeper.GetAuction(s.Ctx, name) + s.Require().NoError(err, "no error expected when getting auction") + return *auction +} + +func (s *KeeperTestSuite) DeleteParams() { + store := s.Ctx.KVStore(s.App.AuctionKeeper.GetStoreKey()) + store.Delete([]byte(types.ParamsKey)) +} diff --git a/x/auction/keeper/msg_server_test.go b/x/auction/keeper/msg_server_test.go new file mode 100644 index 0000000000..29811d2778 --- /dev/null +++ b/x/auction/keeper/msg_server_test.go @@ -0,0 +1,321 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" + icqoracletypes "github.com/Stride-Labs/stride/v24/x/icqoracle/types" +) + +func (s *KeeperTestSuite) TestCreateAuction() { + // Create a new auction + msg := types.MsgCreateAuction{ + AuctionName: "test-auction", + AuctionType: types.AuctionType_AUCTION_TYPE_FCFS, + SellingDenom: "ustrd", + PaymentDenom: "uatom", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyMustNewDecFromStr("0.95"), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: "beneficiary-address", + } + _, err := s.GetMsgServer().CreateAuction(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err, "no error expected when creating auction") + + // Confirm the auction was created + auction := s.MustGetAuction(msg.AuctionName) + + s.Require().Equal(msg.AuctionType, auction.Type, "auction type") + s.Require().Equal(msg.AuctionName, auction.Name, "auction name") + s.Require().Equal(msg.SellingDenom, auction.SellingDenom, "selling denom") + s.Require().Equal(msg.PaymentDenom, auction.PaymentDenom, "payment denom") + s.Require().Equal(msg.Enabled, auction.Enabled, "enabled") + s.Require().Equal(msg.MinPriceMultiplier, auction.MinPriceMultiplier, "min price multiplier") + s.Require().Equal(msg.MinBidAmount, auction.MinBidAmount, "min bid amount") + s.Require().Equal(msg.Beneficiary, auction.Beneficiary, "beneficiary") + s.Require().Equal(sdkmath.ZeroInt(), auction.TotalPaymentTokenReceived, "total payment token received") + s.Require().Equal(sdkmath.ZeroInt(), auction.TotalSellingTokenSold, "total selling token sold") + + // Attempt to create it again, it should fail + _, err = s.GetMsgServer().CreateAuction(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorIs(err, types.ErrAuctionAlreadyExists) +} + +func (s *KeeperTestSuite) TestUpdateAuction() { + // Create an auction first + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "ustrd", + PaymentDenom: "uatom", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: "beneficiary-address", + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Update the auction + msg := types.MsgUpdateAuction{ + AuctionName: auction.Name, + AuctionType: types.AuctionType_AUCTION_TYPE_FCFS, + Enabled: false, + MinPriceMultiplier: sdkmath.LegacyNewDec(2), + MinBidAmount: sdkmath.NewInt(2000), + Beneficiary: "new-beneficiary-address", + } + _, err = s.GetMsgServer().UpdateAuction(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err, "no error expected when updating auction") + + // Confirm the auction was updated + updatedAuction := s.MustGetAuction(msg.AuctionName) + s.Require().Equal(msg.AuctionType, updatedAuction.Type, "auction type") + s.Require().Equal(msg.Enabled, updatedAuction.Enabled, "enabled") + s.Require().Equal(msg.MinPriceMultiplier, updatedAuction.MinPriceMultiplier, "min price multiplier") + s.Require().Equal(msg.MinBidAmount, updatedAuction.MinBidAmount, "min bid amount") + s.Require().Equal(msg.Beneficiary, updatedAuction.Beneficiary, "beneficiary") + + // Try to update non-existent auction, it should fail + msg.AuctionName = "non-existent-auction" + _, err = s.GetMsgServer().UpdateAuction(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorIs(err, types.ErrAuctionDoesntExist) +} + +func (s *KeeperTestSuite) TestPlaceBid() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Create a price + tokenPrice := icqoracletypes.TokenPrice{ + BaseDenom: auction.SellingDenom, + QuoteDenom: auction.PaymentDenom, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1), + UpdatedAt: s.Ctx.BlockTime(), + QueryInProgress: false, + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting tokenPrice") + + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Mint enough selling coins to auction module to sell + s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) + + // Mint enough payment coins to bidder to pay + s.FundAccount(bidder, sdk.NewCoin(auction.PaymentDenom, msg.PaymentTokenAmount)) + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().NoError(err, "no error expected when placing bid") + + // Check payment token to beneficiary + s.Require().Contains(s.Ctx.EventManager().Events(), + sdk.NewEvent( + banktypes.EventTypeTransfer, + sdk.NewAttribute(banktypes.AttributeKeyRecipient, s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String()), + sdk.NewAttribute(banktypes.AttributeKeySender, msg.Bidder), + sdk.NewAttribute(sdk.AttributeKeyAmount, sdk.NewCoins(sdk.NewCoin(auction.PaymentDenom, msg.PaymentTokenAmount)).String()), + ), + ) + + // Check selling token to bidder + s.Require().Contains(s.Ctx.EventManager().Events(), + sdk.NewEvent( + banktypes.EventTypeTransfer, + sdk.NewAttribute(banktypes.AttributeKeyRecipient, msg.Bidder), + sdk.NewAttribute(banktypes.AttributeKeySender, s.App.AccountKeeper.GetModuleAddress(types.ModuleName).String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, sdk.NewCoins(sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)).String()), + ), + ) + + // Check PlaceBid events + s.Require().Contains(s.Ctx.EventManager().Events(), + sdk.NewEvent( + types.EventTypeBidAccepted, + sdk.NewAttribute(types.AttributeKeyAuctionName, auction.Name), + sdk.NewAttribute(types.AttributeKeyBidder, msg.Bidder), + sdk.NewAttribute(types.AttributeKeyPaymentAmount, msg.PaymentTokenAmount.String()), + sdk.NewAttribute(types.AttributeKeyPaymentDenom, auction.PaymentDenom), + sdk.NewAttribute(types.AttributeKeySellingAmount, msg.SellingTokenAmount.String()), + sdk.NewAttribute(types.AttributeKeySellingDenom, auction.SellingDenom), + sdk.NewAttribute(types.AttributeKeyPrice, sdkmath.LegacyNewDec(1).String()), + ), + ) +} + +func (s *KeeperTestSuite) TestPlaceBidUnsupportedAuctionType() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_UNSPECIFIED, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid") + s.Require().Contains(err.Error(), "unsupported auction type") +} + +func (s *KeeperTestSuite) TestPlaceBidAuctionNoFound() { + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: "banana", + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Place Bid + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid") + s.Require().Contains(err.Error(), "cannot get auction for name='banana'") +} + +func (s *KeeperTestSuite) TestPlaceBidNotEnoughSellingTokens() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid") + s.Require().Contains(err.Error(), "bid wants to buy 1000uosmo but auction only has 0uosmo") +} + +func (s *KeeperTestSuite) TestPlaceBidNoPriceForSellingDenom() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Mint enough selling coins to auction module to sell + s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid") + s.Require().Contains(err.Error(), "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for baseDenom 'uosmo'") +} + +func (s *KeeperTestSuite) TestPlaceBidNoPriceForPaymentDenom() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Create a price only for SellingDenom + tokenPrice := icqoracletypes.TokenPrice{ + BaseDenom: auction.SellingDenom, + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1), + UpdatedAt: s.Ctx.BlockTime(), + QueryInProgress: false, + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting tokenPrice") + + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Mint enough selling coins to auction module to sell + s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid") + s.Require().Contains(err.Error(), "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for quoteDenom 'ustrd'") +} From a099a5176fa64bd0475fb43a5d207028fa189ee4 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 27 Jan 2025 17:11:13 +0200 Subject: [PATCH 084/115] auction: test more edge cases --- x/auction/keeper/msg_server_test.go | 110 ++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/x/auction/keeper/msg_server_test.go b/x/auction/keeper/msg_server_test.go index 29811d2778..ad8630920a 100644 --- a/x/auction/keeper/msg_server_test.go +++ b/x/auction/keeper/msg_server_test.go @@ -85,7 +85,7 @@ func (s *KeeperTestSuite) TestUpdateAuction() { s.Require().ErrorIs(err, types.ErrAuctionDoesntExist) } -func (s *KeeperTestSuite) TestPlaceBid() { +func (s *KeeperTestSuite) TestFcfsPlaceBidHappyPath() { // Create an auction auction := types.Auction{ Type: types.AuctionType_AUCTION_TYPE_FCFS, @@ -166,7 +166,7 @@ func (s *KeeperTestSuite) TestPlaceBid() { ) } -func (s *KeeperTestSuite) TestPlaceBidUnsupportedAuctionType() { +func (s *KeeperTestSuite) TestFcfsPlaceBidUnsupportedAuctionType() { // Create an auction auction := types.Auction{ Type: types.AuctionType_AUCTION_TYPE_UNSPECIFIED, @@ -196,7 +196,7 @@ func (s *KeeperTestSuite) TestPlaceBidUnsupportedAuctionType() { s.Require().Contains(err.Error(), "unsupported auction type") } -func (s *KeeperTestSuite) TestPlaceBidAuctionNoFound() { +func (s *KeeperTestSuite) TestFcfsPlaceBidAuctionNoFound() { // Prepare bid bidder := s.TestAccs[0] msg := types.MsgPlaceBid{ @@ -212,7 +212,7 @@ func (s *KeeperTestSuite) TestPlaceBidAuctionNoFound() { s.Require().Contains(err.Error(), "cannot get auction for name='banana'") } -func (s *KeeperTestSuite) TestPlaceBidNotEnoughSellingTokens() { +func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughSellingTokens() { // Create an auction auction := types.Auction{ Type: types.AuctionType_AUCTION_TYPE_FCFS, @@ -242,7 +242,7 @@ func (s *KeeperTestSuite) TestPlaceBidNotEnoughSellingTokens() { s.Require().Contains(err.Error(), "bid wants to buy 1000uosmo but auction only has 0uosmo") } -func (s *KeeperTestSuite) TestPlaceBidNoPriceForSellingDenom() { +func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForSellingDenom() { // Create an auction auction := types.Auction{ Type: types.AuctionType_AUCTION_TYPE_FCFS, @@ -275,7 +275,7 @@ func (s *KeeperTestSuite) TestPlaceBidNoPriceForSellingDenom() { s.Require().Contains(err.Error(), "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for baseDenom 'uosmo'") } -func (s *KeeperTestSuite) TestPlaceBidNoPriceForPaymentDenom() { +func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { // Create an auction auction := types.Auction{ Type: types.AuctionType_AUCTION_TYPE_FCFS, @@ -319,3 +319,101 @@ func (s *KeeperTestSuite) TestPlaceBidNoPriceForPaymentDenom() { s.Require().Error(err, "error expected when placing bid") s.Require().Contains(err.Error(), "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for quoteDenom 'ustrd'") } + +func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: "beneficiary-address", + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Create a price + tokenPrice := icqoracletypes.TokenPrice{ + BaseDenom: auction.SellingDenom, + QuoteDenom: auction.PaymentDenom, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1), + UpdatedAt: s.Ctx.BlockTime(), + QueryInProgress: false, + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting tokenPrice") + + // Prepare bid with a price that's too low + // With spot price = 1 and multiplier = 1, minimum accepted price should be 1 + // Setting bid with price < 1 + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + // Make the effective price 0.5, which is below floor of 1 + SellingTokenAmount: sdkmath.NewInt(2000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Mint enough selling coins to auction module to sell + s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) + + // Mint enough payment coins to bidder to pay + s.FundAccount(bidder, sdk.NewCoin(auction.PaymentDenom, msg.PaymentTokenAmount)) + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid with price too low") + s.Require().Contains(err.Error(), "bid price too low") +} + +func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { + // Create an auction + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "uosmo", + PaymentDenom: "ustrd", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction") + + // Create a price + tokenPrice := icqoracletypes.TokenPrice{ + BaseDenom: auction.SellingDenom, + QuoteDenom: auction.PaymentDenom, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1), + UpdatedAt: s.Ctx.BlockTime(), + QueryInProgress: false, + } + err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + s.Require().NoError(err, "no error expected when setting tokenPrice") + + // Prepare bid + bidder := s.TestAccs[0] + msg := types.MsgPlaceBid{ + AuctionName: auction.Name, + Bidder: bidder.String(), + SellingTokenAmount: sdkmath.NewInt(1000), + PaymentTokenAmount: sdkmath.NewInt(1000), + } + + // Mint enough selling coins to auction module to sell + s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) + + // DON'T fund the bidder with payment tokens + + // Place Bid + _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().Error(err, "error expected when placing bid") + s.Require().Contains(err.Error(), "failed to send payment tokens from bidder") +} From 59fa3ee3fb9983232a20e19fecc0638e21c15a2b Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 27 Jan 2025 17:22:40 +0200 Subject: [PATCH 085/115] Fix auction store prefix iteration --- x/auction/keeper/keeper.go | 2 +- x/auction/keeper/params_test.go | 13 +++++ x/auction/keeper/query_test.go | 91 +++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 x/auction/keeper/params_test.go create mode 100644 x/auction/keeper/query_test.go diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index d6a9486597..9ecdeb85a3 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -71,7 +71,7 @@ func (k Keeper) GetAuction(ctx sdk.Context, name string) (*types.Auction, error) // GetAllAuctions retrieves all stored auctions func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.AuctionPrefix)) + iterator := store.Iterator(nil, nil) defer iterator.Close() auctions := []types.Auction{} diff --git a/x/auction/keeper/params_test.go b/x/auction/keeper/params_test.go new file mode 100644 index 0000000000..c3abc4d338 --- /dev/null +++ b/x/auction/keeper/params_test.go @@ -0,0 +1,13 @@ +package keeper_test + +import "github.com/Stride-Labs/stride/v24/x/auction/types" + +func (s *KeeperTestSuite) TestParams() { + expectedParams := types.Params{} + err := s.App.AuctionKeeper.SetParams(s.Ctx, expectedParams) + s.Require().NoError(err, "should not error on set params") + + actualParams, err := s.App.AuctionKeeper.GetParams(s.Ctx) + s.Require().NoError(err, "should not error on get params") + s.Require().Equal(expectedParams, actualParams, "params") +} diff --git a/x/auction/keeper/query_test.go b/x/auction/keeper/query_test.go new file mode 100644 index 0000000000..6eb7fef88c --- /dev/null +++ b/x/auction/keeper/query_test.go @@ -0,0 +1,91 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/auction/types" +) + +func (s *KeeperTestSuite) TestQueryAuction() { + // Create an auction + expectedAuction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction", + SellingDenom: "ustrd", + PaymentDenom: "uatom", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: "beneficiary-address", + TotalSellingTokenSold: sdkmath.ZeroInt(), + TotalPaymentTokenReceived: sdkmath.ZeroInt(), + } + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &expectedAuction) + s.Require().NoError(err, "no error expected when setting auction") + + // Query for the auction + req := &types.QueryAuctionRequest{ + Name: expectedAuction.Name, + } + resp, err := s.App.AuctionKeeper.Auction(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying auction") + s.Require().Equal(expectedAuction, resp.Auction, "auction") + + // Query with invalid request + _, err = s.App.AuctionKeeper.Auction(sdk.WrapSDKContext(s.Ctx), nil) + s.Require().Error(err, "error expected when querying with nil request") + + // Query with non-existent auction + reqNonExistent := &types.QueryAuctionRequest{ + Name: "non-existent-auction", + } + _, err = s.App.AuctionKeeper.Auction(sdk.WrapSDKContext(s.Ctx), reqNonExistent) + s.Require().Error(err, "error expected when querying non-existent auction") + s.Require().Contains(err.Error(), "auction not found") +} + +func (s *KeeperTestSuite) TestQueryAuctions() { + // Create multiple auctions + expectedAuctions := []types.Auction{ + { + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction-1", + SellingDenom: "ustrd", + PaymentDenom: "uatom", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(1), + MinBidAmount: sdkmath.NewInt(1000), + Beneficiary: "beneficiary-address-1", + TotalSellingTokenSold: sdkmath.ZeroInt(), + TotalPaymentTokenReceived: sdkmath.ZeroInt(), + }, + { + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: "test-auction-2", + SellingDenom: "ustrd", + PaymentDenom: "uosmo", + Enabled: true, + MinPriceMultiplier: sdkmath.LegacyNewDec(2), + MinBidAmount: sdkmath.NewInt(2000), + Beneficiary: "beneficiary-address-2", + TotalSellingTokenSold: sdkmath.ZeroInt(), + TotalPaymentTokenReceived: sdkmath.ZeroInt(), + }, + } + + for _, auction := range expectedAuctions { + err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + s.Require().NoError(err, "no error expected when setting auction %+v", auction) + } + + // Query all auctions + req := &types.QueryAuctionsRequest{} + resp, err := s.App.AuctionKeeper.Auctions(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying all auctions") + s.Require().Equal(expectedAuctions, resp.Auctions, "auctions") + + // Query with invalid request + _, err = s.App.AuctionKeeper.Auctions(sdk.WrapSDKContext(s.Ctx), nil) + s.Require().Error(err, "error expected when querying with nil request") +} From 4fb218f2c0a006c2e06d735da6fdcfc51ad28945 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 27 Jan 2025 17:45:52 +0200 Subject: [PATCH 086/115] strdburner tests --- x/strdburner/keeper/abci_test.go | 79 ++++++++++++++++++++++++++++++ x/strdburner/keeper/keeper_test.go | 70 ++++++++++++++++++++++++++ x/strdburner/keeper/query_test.go | 28 +++++++++++ 3 files changed, 177 insertions(+) create mode 100644 x/strdburner/keeper/abci_test.go create mode 100644 x/strdburner/keeper/keeper_test.go create mode 100644 x/strdburner/keeper/query_test.go diff --git a/x/strdburner/keeper/abci_test.go b/x/strdburner/keeper/abci_test.go new file mode 100644 index 0000000000..f15a387c26 --- /dev/null +++ b/x/strdburner/keeper/abci_test.go @@ -0,0 +1,79 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/Stride-Labs/stride/v24/x/strdburner/keeper" + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +func (s *KeeperTestSuite) TestEndBlocker() { + t := s.T() + burnerAddress := s.App.StrdBurnerKeeper.GetStrdBurnerAddress() + + tests := []struct { + name string + initialBalance sdk.Coin + shouldBurn bool + }{ + { + name: "burn non-zero balance", + initialBalance: sdk.NewCoin("ustrd", sdk.NewInt(1000)), + shouldBurn: true, + }, + { + name: "zero balance - no burn", + initialBalance: sdk.NewCoin("ustrd", sdk.NewInt(0)), + shouldBurn: false, + }, + } + + for _, tc := range tests { + s.Run(tc.name, func() { + // Setup test state + s.SetupTest() + + // Set initial balance if non-zero + if !tc.initialBalance.IsZero() { + s.FundModuleAccount(types.ModuleName, tc.initialBalance) + } + + // Verify initial state + initialBalance := s.App.BankKeeper.GetBalance(s.Ctx, burnerAddress, "ustrd") + require.Equal(t, tc.initialBalance, initialBalance) + + initialTotalBurned := s.App.StrdBurnerKeeper.GetTotalStrdBurned(s.Ctx) + require.Equal(t, sdk.ZeroInt(), initialTotalBurned) + + // Run EndBlocker + keeper.EndBlocker(s.Ctx, s.App.StrdBurnerKeeper) + + // Verify final state + finalBalance := s.App.BankKeeper.GetBalance(s.Ctx, burnerAddress, "ustrd") + require.Equal(t, sdk.NewCoin("ustrd", sdk.ZeroInt()), finalBalance) + + finalTotalBurned := s.App.StrdBurnerKeeper.GetTotalStrdBurned(s.Ctx) + if tc.shouldBurn { + require.Equal(t, tc.initialBalance.Amount, finalTotalBurned) + + // Verify event was emitted + events := s.Ctx.EventManager().Events() + var found bool + for _, event := range events { + if event.Type == types.EventTypeBurn { + found = true + for _, attr := range event.Attributes { + if string(attr.Key) == types.AttributeAmount { + require.Equal(t, tc.initialBalance.String(), string(attr.Value)) + } + } + } + } + require.True(t, found, "burn event should have been emitted") + } else { + require.Equal(t, sdk.ZeroInt(), finalTotalBurned) + } + }) + } +} diff --git a/x/strdburner/keeper/keeper_test.go b/x/strdburner/keeper/keeper_test.go new file mode 100644 index 0000000000..47c849caab --- /dev/null +++ b/x/strdburner/keeper/keeper_test.go @@ -0,0 +1,70 @@ +package keeper_test + +import ( + "bytes" + "testing" + + "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/log" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/Stride-Labs/stride/v24/app/apptesting" + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +type KeeperTestSuite struct { + apptesting.AppTestHelper + logBuffer bytes.Buffer +} + +func (s *KeeperTestSuite) SetupTest() { + s.Setup() + + // Create a logger with accessible output + logger := log.NewTMLogger(&s.logBuffer) + s.Ctx = s.Ctx.WithLogger(logger) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (s *KeeperTestSuite) TestGetStrdBurnerAddress() { + address := s.App.StrdBurnerKeeper.GetStrdBurnerAddress() + require.NotNil(s.T(), address) + require.Equal(s.T(), types.ModuleName, s.App.AccountKeeper.GetModuleAccount(s.Ctx, types.ModuleName).GetName()) +} + +func (s *KeeperTestSuite) TestSetAndGetTotalStrdBurned() { + // Test initial state (should be zero) + initialAmount := s.App.StrdBurnerKeeper.GetTotalStrdBurned(s.Ctx) + require.Equal(s.T(), math.ZeroInt(), initialAmount) + + // Clear any potential existing value to explicitly test nil case + store := s.Ctx.KVStore(s.App.GetKey(types.StoreKey)) + store.Delete([]byte(types.TotalStrdBurnedKey)) + + // Test getting value when none exists (should return zero) + nilAmount := s.App.StrdBurnerKeeper.GetTotalStrdBurned(s.Ctx) + require.Equal(s.T(), math.ZeroInt(), nilAmount) + + // Test setting and getting a value + testAmount := math.NewInt(1000) + s.App.StrdBurnerKeeper.SetTotalStrdBurned(s.Ctx, testAmount) + + storedAmount := s.App.StrdBurnerKeeper.GetTotalStrdBurned(s.Ctx) + require.Equal(s.T(), testAmount, storedAmount) + + // Test updating the value + newAmount := math.NewInt(2000) + s.App.StrdBurnerKeeper.SetTotalStrdBurned(s.Ctx, newAmount) + + updatedAmount := s.App.StrdBurnerKeeper.GetTotalStrdBurned(s.Ctx) + require.Equal(s.T(), newAmount, updatedAmount) +} + +func (s *KeeperTestSuite) TestLogger() { + logger := s.App.StrdBurnerKeeper.Logger(s.Ctx) + require.NotNil(s.T(), logger) +} diff --git a/x/strdburner/keeper/query_test.go b/x/strdburner/keeper/query_test.go new file mode 100644 index 0000000000..a630006332 --- /dev/null +++ b/x/strdburner/keeper/query_test.go @@ -0,0 +1,28 @@ +package keeper_test + +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v24/x/strdburner/types" +) + +func (s *KeeperTestSuite) TestQueryStrdBurnerAddress() { + // Query for the strd burner address + req := &types.QueryStrdBurnerAddressRequest{} + resp, err := s.App.StrdBurnerKeeper.StrdBurnerAddress(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying strd burner address") + s.Require().Equal(s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), resp.Address, "address") +} + +func (s *KeeperTestSuite) TestQueryTotalStrdBurned() { + // Set initial total burned amount + expectedAmount := sdkmath.NewInt(1000000) + s.App.StrdBurnerKeeper.SetTotalStrdBurned(s.Ctx, expectedAmount) + + // Query for the total burned amount + req := &types.QueryTotalStrdBurnedRequest{} + resp, err := s.App.StrdBurnerKeeper.TotalStrdBurned(sdk.WrapSDKContext(s.Ctx), req) + s.Require().NoError(err, "no error expected when querying total strd burned") + s.Require().Equal(expectedAmount, resp.TotalBurned, "total burned amount") +} From 9ad0f444047d2f7f1d35d31fad535e7cb6a64d9d Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 27 Jan 2025 17:45:58 +0200 Subject: [PATCH 087/115] go mod tidy --- go.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5af04d845f..6425ffb199 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 google.golang.org/grpc v1.62.1 + google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -163,6 +164,7 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/viper v1.19.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect @@ -193,7 +195,6 @@ require ( google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect From 6168bdd78517517c3b97236121718e93f8c2e0cd Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 27 Jan 2025 21:47:26 +0200 Subject: [PATCH 088/115] k8s checkpoint --- integration-tests/Makefile | 7 ++-- integration-tests/client/README.md | 4 ++- integration-tests/client/package.json | 7 ++-- integration-tests/client/pnpm-lock.yaml | 10 +++--- integration-tests/client/vitest.config.ts | 26 +++++++++++++++ ...Dockerfile.cosmos => Dockerfile.cosmoshub} | 0 .../dockerfiles/Dockerfile.osmosis | 32 +++++++++++++++++++ integration-tests/network/values.yaml | 19 +++++++++-- 8 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 integration-tests/client/vitest.config.ts rename integration-tests/dockerfiles/{Dockerfile.cosmos => Dockerfile.cosmoshub} (100%) create mode 100644 integration-tests/dockerfiles/Dockerfile.osmosis diff --git a/integration-tests/Makefile b/integration-tests/Makefile index dff11dfc3f..67acf88af3 100644 --- a/integration-tests/Makefile +++ b/integration-tests/Makefile @@ -46,8 +46,11 @@ build-api: build-stride: @bash network/scripts/build.sh stride -build-cosmos: - $(call build_and_push_docker,cosmos,.,chains/cosmoshub:v18.1.0) +build-cosmoshub: + $(call build_and_push_docker,cosmoshub,.,chains/cosmoshub:v18.1.0) + +build-osmosis: + $(call build_and_push_docker,osmosis,.,chains/osmosis:v27.0.0) build-relayer: $(call build_and_push_docker,relayer,.,relayer:v2.5.2) diff --git a/integration-tests/client/README.md b/integration-tests/client/README.md index 32959aa8e2..011fc0faf8 100644 --- a/integration-tests/client/README.md +++ b/integration-tests/client/README.md @@ -23,9 +23,11 @@ IMPORTANT: `@cosmjs/*` dependencies must match the versions used by stridejs. To ### test new protobufs - go to https://github.com/Stride-Labs/stridejs - - update the config in `scripts/clone_repos.ts` to point to the new `stride`, `cosmos-sdk`, `ibc-go`, `wasmd` versions + - remove `/dist` from `.gitignore` + - update the config in `scripts/clone_repos.ts` to point to the new `stride/cosmos-sdk/ibc-go` version - run `pnpm i` - run `pnpm codegen` + - run `pnpm build` - run `git commit...` - run `git push` - get the current `stridejs` commit using `git rev-parse HEAD` diff --git a/integration-tests/client/package.json b/integration-tests/client/package.json index caa3f71fd4..3dfef7a28a 100644 --- a/integration-tests/client/package.json +++ b/integration-tests/client/package.json @@ -1,10 +1,11 @@ { "name": "stride-integration-tests", "version": "1.0.0", + "type": "module", "description": "integration tests for stride chain", "scripts": { - "test": "vitest run", - "test-watch": "vitest watch" + "test": "NODE_OPTIONS=--conditions=node vitest run", + "test-watch": "NODE_OPTIONS=--conditions=node vitest watch" }, "keywords": [ "wow", @@ -25,7 +26,7 @@ "bech32": "2.0.0", "jest": "29.7.0", "prettier": "3.3.3", - "stridejs": "github:Stride-Labs/stridejs#f5ad6abac646aff015676fff508bc842f53951ef", + "stridejs": "github:Stride-Labs/stridejs#e949e35", "typescript": "5.5.3", "vitest": "2.0.3" }, diff --git a/integration-tests/client/pnpm-lock.yaml b/integration-tests/client/pnpm-lock.yaml index 3c33853910..79354fd853 100644 --- a/integration-tests/client/pnpm-lock.yaml +++ b/integration-tests/client/pnpm-lock.yaml @@ -42,8 +42,8 @@ importers: specifier: 3.3.3 version: 3.3.3 stridejs: - specifier: github:Stride-Labs/stridejs#f5ad6abac646aff015676fff508bc842f53951ef - version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f5ad6abac646aff015676fff508bc842f53951ef + specifier: github:Stride-Labs/stridejs#e949e35 + version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35 typescript: specifier: 5.5.3 version: 5.5.3 @@ -1669,8 +1669,8 @@ packages: std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f5ad6abac646aff015676fff508bc842f53951ef: - resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f5ad6abac646aff015676fff508bc842f53951ef} + stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: + resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35} version: 0.11.4 string-length@4.0.2: @@ -3825,7 +3825,7 @@ snapshots: std-env@3.7.0: {} - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f5ad6abac646aff015676fff508bc842f53951ef: + stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: dependencies: '@cosmjs/amino': 0.32.4 '@cosmjs/encoding': 0.32.4 diff --git a/integration-tests/client/vitest.config.ts b/integration-tests/client/vitest.config.ts new file mode 100644 index 0000000000..c5659342b7 --- /dev/null +++ b/integration-tests/client/vitest.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + globals: true, + environment: "node", + testTimeout: 30000, + hookTimeout: 30000, + pool: "forks", + poolOptions: { + forks: { + singleFork: true, + }, + }, + server: { + deps: { + inline: ["stridejs"], + }, + }, + }, + resolve: { + alias: { + stridejs: "stridejs/dist/esm", // Force ESM path + }, + }, +}); diff --git a/integration-tests/dockerfiles/Dockerfile.cosmos b/integration-tests/dockerfiles/Dockerfile.cosmoshub similarity index 100% rename from integration-tests/dockerfiles/Dockerfile.cosmos rename to integration-tests/dockerfiles/Dockerfile.cosmoshub diff --git a/integration-tests/dockerfiles/Dockerfile.osmosis b/integration-tests/dockerfiles/Dockerfile.osmosis new file mode 100644 index 0000000000..6db9df8395 --- /dev/null +++ b/integration-tests/dockerfiles/Dockerfile.osmosis @@ -0,0 +1,32 @@ +FROM golang:1.23-alpine3.21 AS builder + +WORKDIR /opt + +RUN apk add --update curl make git libc-dev bash gcc linux-headers eudev-dev ca-certificates build-base git + +ENV REPO=https://github.com/osmosis-labs/osmosis +ENV COMMIT_HASH=v27.0.0 +ENV BINARY=osmosisd + +RUN git clone ${REPO} chain \ + && cd chain \ + && git checkout $COMMIT_HASH + +WORKDIR /opt/chain + +RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \ + -O /lib/libwasmvm_muslc.$ARCH.a + +RUN BUILD_TAGS=muslc LINK_STATICALLY=true make install + +FROM alpine:3.21 +COPY --from=builder /go/bin/$BINARY /usr/local/bin/ +RUN apk add bash vim sudo dasel jq curl \ + && addgroup -g 1000 validator \ + && adduser -S -h /home/validator -D validator -u 1000 -G validator + +USER 1000 +WORKDIR /home/validator + +EXPOSE 26657 26656 1317 9090 diff --git a/integration-tests/network/values.yaml b/integration-tests/network/values.yaml index 45fff8a88b..7e66d5021a 100644 --- a/integration-tests/network/values.yaml +++ b/integration-tests/network/values.yaml @@ -18,15 +18,28 @@ chains: - name: cosmoshub binary: gaiad version: v18.1.0 - numValidators: 3 + numValidators: 1 home: .gaia denom: uatom decimals: 6 command: ["gaiad", "start"] + - name: osmosis + binary: osmosisd + version: v27.0.0 + numValidators: 1 + home: .osmosisd + denom: uosmo + decimals: 6 + command: ["sleep", "infinity"] + # type can be either "relayer" or "hermes" relayers: - name: stride-cosmoshub - type: relayer + type: hermes + chainA: stride + chainB: cosmoshub + - name: stride-osmosis + type: hermes chainA: stride - chainB: cosmoshub \ No newline at end of file + chainB: osmosis From 581106a1141345a1526325e8123e0249a1612497 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 30 Jan 2025 20:40:24 +0200 Subject: [PATCH 089/115] Updates Osmosis to v28.0.0 and adds Gaia test setup Upgrades Osmosis chain version from v27.0.0 to v28.0.0 across all relevant configuration files Adds Gaia test client initialization and chain startup validation to integration tests for more comprehensive testing coverage --- integration-tests/Makefile | 5 +--- integration-tests/client/test/main.test.ts | 25 +++++++++++++++++-- .../dockerfiles/Dockerfile.osmosis | 2 +- integration-tests/network/values.yaml | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/integration-tests/Makefile b/integration-tests/Makefile index f3fa4186fb..336168ccce 100644 --- a/integration-tests/Makefile +++ b/integration-tests/Makefile @@ -55,10 +55,7 @@ build-cosmoshub: $(call build_and_push_docker,cosmoshub,.,chains/cosmoshub:v18.1.0) build-osmosis: - $(call build_and_push_docker,osmosis,.,chains/osmosis:v27.0.0) - -build-osmosis: - $(call build_and_push_docker,osmosis,.,chains/osmosis:v27.0.0) + $(call build_and_push_docker,osmosis,.,chains/osmosis:v28.0.0) build-relayer: $(call build_and_push_docker,relayer,.,relayer:v2.5.2) diff --git a/integration-tests/client/test/main.test.ts b/integration-tests/client/test/main.test.ts index 56e81cf2a3..3c68b5131c 100644 --- a/integration-tests/client/test/main.test.ts +++ b/integration-tests/client/test/main.test.ts @@ -5,13 +5,13 @@ import { coinFromString, convertBech32Prefix, decToString, - sleep, StrideClient, } from "stridejs"; import { beforeAll, describe, expect, test } from "vitest"; import { waitForChain } from "./utils"; const RPC_ENDPOINT = "http://stride-rpc.internal.stridenet.co"; +const HUB_RPC_ENDPOINT = "http://localhost:26557"; let accounts: { user: StrideClient; // a normal account loaded with 100 STRD @@ -21,6 +21,10 @@ let accounts: { val3: StrideClient; }; +let gaiaAccounts: { + user: StrideClient; // a normal account loaded with 100 ATOM +}; + // init accounts and wait for chain to start beforeAll(async () => { console.log("setting up accounts..."); @@ -78,10 +82,27 @@ beforeAll(async () => { broadcastPollIntervalMs: 50, resolveIbcResponsesCheckIntervalMs: 50, }); - } + if (name === "user") { + const signer = await Secp256k1HdWallet.fromMnemonic(mnemonic); + + // get signer address + const [{ address }] = await signer.getAccounts(); + + gaiaAccounts = { + user: await StrideClient.create(HUB_RPC_ENDPOINT, signer, address, { + gasPrice: GasPrice.fromString("0.025uatom"), + broadcastPollIntervalMs: 50, + resolveIbcResponsesCheckIntervalMs: 50, + }), + }; + } + } console.log("waiting for stride to start..."); await waitForChain(accounts.user, "ustrd"); + + console.log("waiting for gaia to start..."); + await waitForChain(gaiaAccounts.user, "uatom"); }); // time variables in seconds diff --git a/integration-tests/dockerfiles/Dockerfile.osmosis b/integration-tests/dockerfiles/Dockerfile.osmosis index 27dba1da86..154ecc74b8 100644 --- a/integration-tests/dockerfiles/Dockerfile.osmosis +++ b/integration-tests/dockerfiles/Dockerfile.osmosis @@ -5,7 +5,7 @@ WORKDIR /opt RUN apk add --update curl make git libc-dev bash gcc linux-headers eudev-dev ca-certificates build-base git ENV REPO=https://github.com/osmosis-labs/osmosis -ENV COMMIT_HASH=v27.0.0 +ENV COMMIT_HASH=v28.0.0 ENV BINARY=osmosisd RUN git clone ${REPO} chain \ diff --git a/integration-tests/network/values.yaml b/integration-tests/network/values.yaml index 9a26b579a3..cc137d56f8 100644 --- a/integration-tests/network/values.yaml +++ b/integration-tests/network/values.yaml @@ -26,7 +26,7 @@ chains: - name: osmosis binary: osmosisd - version: v27.0.0 + version: v28.0.0 numValidators: 1 home: .osmosisd denom: uosmo From c8e79e5a454a7a97d46668a06878b8d97b81966d Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Thu, 30 Jan 2025 20:49:36 +0200 Subject: [PATCH 090/115] Adds IBC transfer channels and test infrastructure Restructures test setup to support multi-chain IBC testing: - Defines transfer channels between Stride, Gaia, and Osmosis - Improves code organization by moving mnemonics outside beforeAll - Adds comprehensive ICQ oracle testing with packet forwarding - Enhances code comments for better clarity The changes enable more thorough integration testing of cross-chain functionality. --- integration-tests/client/test/main.test.ts | 193 ++++++++++++++++----- 1 file changed, 148 insertions(+), 45 deletions(-) diff --git a/integration-tests/client/test/main.test.ts b/integration-tests/client/test/main.test.ts index 3c68b5131c..a2cf919675 100644 --- a/integration-tests/client/test/main.test.ts +++ b/integration-tests/client/test/main.test.ts @@ -10,8 +10,15 @@ import { import { beforeAll, describe, expect, test } from "vitest"; import { waitForChain } from "./utils"; -const RPC_ENDPOINT = "http://stride-rpc.internal.stridenet.co"; -const HUB_RPC_ENDPOINT = "http://localhost:26557"; +const STRIDE_RPC_ENDPOINT = "http://stride-rpc.internal.stridenet.co"; +const GAIA_RPC_ENDPOINT = "http://cosmoshub-rpc.internal.stridenet.co"; +const OSMO_RPC_ENDPOINT = "http://localhost:26357"; + +const TRANSFER_CHANNEL = { + STRIDE: { GAIA: "channel-0", OSMO: "channel-1" }, + GAIA: { STRIDE: "channel-0" }, + OSMO: { STRIDE: "channel-0" }, +}; let accounts: { user: StrideClient; // a normal account loaded with 100 STRD @@ -25,51 +32,50 @@ let gaiaAccounts: { user: StrideClient; // a normal account loaded with 100 ATOM }; +const mnemonics: { + name: "user" | "admin" | "val1" | "val2" | "val3"; + mnemonic: string; +}[] = [ + { + name: "user", + mnemonic: + "brief play describe burden half aim soccer carbon hope wait output play vacuum joke energy crucial output mimic cruise brother document rail anger leaf", + }, + { + name: "admin", + mnemonic: + "tone cause tribe this switch near host damage idle fragile antique tail soda alien depth write wool they rapid unfold body scan pledge soft", + }, + { + name: "val1", + mnemonic: + "close soup mirror crew erode defy knock trigger gather eyebrow tent farm gym gloom base lemon sleep weekend rich forget diagram hurt prize fly", + }, + { + name: "val2", + mnemonic: + "turkey miss hurry unable embark hospital kangaroo nuclear outside term toy fall buffalo book opinion such moral meadow wing olive camp sad metal banner", + }, + { + name: "val3", + mnemonic: + "tenant neck ask season exist hill churn rice convince shock modify evidence armor track army street stay light program harvest now settle feed wheat", + }, +]; + // init accounts and wait for chain to start beforeAll(async () => { console.log("setting up accounts..."); - - const mnemonics: { - name: "user" | "admin" | "val1" | "val2" | "val3"; - mnemonic: string; - }[] = [ - { - name: "user", - mnemonic: - "brief play describe burden half aim soccer carbon hope wait output play vacuum joke energy crucial output mimic cruise brother document rail anger leaf", - }, - { - name: "admin", - mnemonic: - "tone cause tribe this switch near host damage idle fragile antique tail soda alien depth write wool they rapid unfold body scan pledge soft", - }, - { - name: "val1", - mnemonic: - "close soup mirror crew erode defy knock trigger gather eyebrow tent farm gym gloom base lemon sleep weekend rich forget diagram hurt prize fly", - }, - { - name: "val2", - mnemonic: - "turkey miss hurry unable embark hospital kangaroo nuclear outside term toy fall buffalo book opinion such moral meadow wing olive camp sad metal banner", - }, - { - name: "val3", - mnemonic: - "tenant neck ask season exist hill churn rice convince shock modify evidence armor track army street stay light program harvest now settle feed wheat", - }, - ]; - // @ts-expect-error // init accounts as an empty object, then add the accounts in the loop accounts = {}; for (const { name, mnemonic } of mnemonics) { // setup signer // - // IMPORTANT: we're using Secp256k1HdWallet from @cosmjs/amino because sending amino txs tests both amino and direct. - // that's because the tx contains the direct encoding anyway, and also attaches a signature on the amino encoding. - // the mempool then converts from direct to amino to verify the signature. - // therefore if the signature verification passes, we can be sure that both amino and direct are supported. + // IMPORTANT: We're using Secp256k1HdWallet from @cosmjs/amino because sending amino txs tests both amino and direct. + // That's because the tx contains the direct encoding anyway, and also attaches a signature on the amino encoding. + // The mempool then converts from direct to amino to verify the signature. + // Therefore if the signature verification passes, we can be sure that both amino and direct are working properly. const signer = await Secp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "stride", }); @@ -77,11 +83,16 @@ beforeAll(async () => { // get signer address const [{ address }] = await signer.getAccounts(); - accounts[name] = await StrideClient.create(RPC_ENDPOINT, signer, address, { - gasPrice: GasPrice.fromString("0.025ustrd"), - broadcastPollIntervalMs: 50, - resolveIbcResponsesCheckIntervalMs: 50, - }); + accounts[name] = await StrideClient.create( + STRIDE_RPC_ENDPOINT, + signer, + address, + { + gasPrice: GasPrice.fromString("0.025ustrd"), + broadcastPollIntervalMs: 50, + resolveIbcResponsesCheckIntervalMs: 50, + }, + ); if (name === "user") { const signer = await Secp256k1HdWallet.fromMnemonic(mnemonic); @@ -90,7 +101,7 @@ beforeAll(async () => { const [{ address }] = await signer.getAccounts(); gaiaAccounts = { - user: await StrideClient.create(HUB_RPC_ENDPOINT, signer, address, { + user: await StrideClient.create(GAIA_RPC_ENDPOINT, signer, address, { gasPrice: GasPrice.fromString("0.025uatom"), broadcastPollIntervalMs: 50, resolveIbcResponsesCheckIntervalMs: 50, @@ -158,7 +169,7 @@ describe("ibc", () => { stridejs.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( { sourcePort: "transfer", - sourceChannel: "channel-0", + sourceChannel: TRANSFER_CHANNEL["STRIDE"]["GAIA"], token: coinFromString("1ustrd"), sender: stridejs.address, receiver: convertBech32Prefix(stridejs.address, "cosmos"), @@ -184,3 +195,95 @@ describe("ibc", () => { expect(ibcAck.tx.code).toBe(0); }, 30_000); }); + +describe("x/icqoracle", () => { + test.only("happy path", async () => { + const stridejs = accounts.user; + + let msg = + stridejs.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( + { + sourcePort: "transfer", + sourceChannel: TRANSFER_CHANNEL["STRIDE"]["OSMO"], + token: coinFromString("1000000ustrd"), + sender: stridejs.address, + receiver: convertBech32Prefix(stridejs.address, "osmo"), + timeoutHeight: { + revisionNumber: 0n, + revisionHeight: 0n, + }, + timeoutTimestamp: BigInt( + `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes from now as nanoseconds + ), + memo: "", + }, + ); + + let tx = await stridejs.signAndBroadcast([msg]); + if (tx.code !== 0) { + console.error(tx.rawLog); + } + expect(tx.code).toBe(0); + + let ibcAck = await tx.ibcResponses[0]; + expect(ibcAck.type).toBe("ack"); + expect(ibcAck.tx.code).toBe(0); + + const gaiaSigner = await Secp256k1HdWallet.fromMnemonic( + mnemonics.find((x) => x.name === "user")!.mnemonic, + { + prefix: "cosmos", + }, + ); + + // get signer address + const [{ address: gaiaAddress }] = await gaiaSigner.getAccounts(); + + const gaiaClient = await StrideClient.create( + GAIA_RPC_ENDPOINT, + gaiaSigner, + gaiaAddress, + { + gasPrice: GasPrice.fromString("0uatom"), + broadcastPollIntervalMs: 50, + resolveIbcResponsesCheckIntervalMs: 50, + }, + ); + + msg = + gaiaClient.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( + { + sourcePort: "transfer", + sourceChannel: TRANSFER_CHANNEL["GAIA"]["STRIDE"], + token: coinFromString("1000000uatom"), + sender: gaiaAddress, + receiver: convertBech32Prefix(gaiaAddress, "stride"), // ignored by pfm + timeoutHeight: { + revisionNumber: 0n, + revisionHeight: 0n, + }, + timeoutTimestamp: BigInt( + `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes from now as nanoseconds + ), + memo: JSON.stringify({ + forward: { + receiver: convertBech32Prefix(gaiaAddress, "osmo"), + port: "transfer", + channel: TRANSFER_CHANNEL["STRIDE"]["OSMO"], + }, + }), + }, + ); + + tx = await stridejs.signAndBroadcast([msg]); + if (tx.code !== 0) { + console.error(tx.rawLog); + } + expect(tx.code).toBe(0); + + // packet forward should resolve only after the final destination is acked + ibcAck = await tx.ibcResponses[0]; + expect(ibcAck.type).toBe("ack"); + expect(ibcAck.tx.code).toBe(0); + }, 120_000); +}); From dbdaf926d8d0dd747c8137091cee20e8011de61c Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 10:19:43 +0200 Subject: [PATCH 091/115] remove unnecessary indirection when calling AuctionOffRewardCollectorBalance --- x/stakeibc/keeper/hooks.go | 2 +- x/stakeibc/keeper/reward_allocation.go | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/x/stakeibc/keeper/hooks.go b/x/stakeibc/keeper/hooks.go index b15aa862e7..8d23c22337 100644 --- a/x/stakeibc/keeper/hooks.go +++ b/x/stakeibc/keeper/hooks.go @@ -89,7 +89,7 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInf k.TransferAllRewardTokens(ctx) } if epochInfo.Identifier == epochstypes.MINT_EPOCH { - k.AllocateRewardsFromHostZones(ctx) + k.AuctionOffRewardCollectorBalance(ctx) } } diff --git a/x/stakeibc/keeper/reward_allocation.go b/x/stakeibc/keeper/reward_allocation.go index 8af660f137..a168b4c789 100644 --- a/x/stakeibc/keeper/reward_allocation.go +++ b/x/stakeibc/keeper/reward_allocation.go @@ -25,8 +25,3 @@ func (k Keeper) AuctionOffRewardCollectorBalance(ctx sdk.Context) { k.Logger(ctx).Info("Cannot send rewards from RewardCollector to Auction module: %w", err) } } - -// AllocateRewardsFromHostZones auctions off the reward collector balance -func (k Keeper) AllocateRewardsFromHostZones(ctx sdk.Context) { - k.AuctionOffRewardCollectorBalance(ctx) -} From 8903f4d882399929a58a4ad0dbcc6ea200d7f629 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 10:21:00 +0200 Subject: [PATCH 092/115] Update x/stakeibc/keeper/reward_allocation.go fix log Co-authored-by: sampocs --- x/stakeibc/keeper/reward_allocation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/stakeibc/keeper/reward_allocation.go b/x/stakeibc/keeper/reward_allocation.go index a168b4c789..765bc141c8 100644 --- a/x/stakeibc/keeper/reward_allocation.go +++ b/x/stakeibc/keeper/reward_allocation.go @@ -22,6 +22,6 @@ func (k Keeper) AuctionOffRewardCollectorBalance(ctx sdk.Context) { err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.RewardCollectorName, auctiontypes.ModuleName, rewardCollectorBalances) if err != nil { - k.Logger(ctx).Info("Cannot send rewards from RewardCollector to Auction module: %w", err) + k.Logger(ctx).Error(fmt.Sprintf("Cannot send rewards from RewardCollector to Auction module: %s", err)) } } From f132e15ad918f385028477b11c41b6f069771480 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 11:44:01 +0200 Subject: [PATCH 093/115] normalize price feeds from Osmosis by adjusting for decimal differences between base and quote tokens For example, when querying BTC (8 decimals) against USDC (6 decimals), the price is automatically adjusted by multiplying by 10^(8-6) to maintain proper price representation. Otherwise a price of 100,000 returns from Osmosis as 1,000. --- proto/stride/icqoracle/icqoracle.proto | 20 +-- proto/stride/icqoracle/tx.proto | 12 +- x/auction/types/auction.pb.go | 70 ++++----- x/auction/types/genesis.pb.go | 4 +- x/auction/types/query.pb.go | 6 +- x/auction/types/tx.pb.go | 92 ++++++------ x/icqoracle/client/cli/tx.go | 21 ++- x/icqoracle/keeper/icq.go | 34 ++++- x/icqoracle/keeper/icq_test.go | 165 ++++++++++++++++++--- x/icqoracle/types/genesis.go | 2 + x/icqoracle/types/genesis.pb.go | 4 +- x/icqoracle/types/icqoracle.pb.go | 192 +++++++++++++++++-------- x/icqoracle/types/msgs.go | 27 +++- x/icqoracle/types/query.pb.go | 74 +++++----- x/icqoracle/types/tx.pb.go | 152 +++++++++++++++----- x/icqoracle/types/validate.go | 16 ++- x/strdburner/types/genesis.pb.go | 4 +- x/strdburner/types/query.pb.go | 4 +- 18 files changed, 628 insertions(+), 271 deletions(-) diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index 07f07cfa1d..ab5a2eec52 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -8,29 +8,33 @@ option go_package = "github.com/Stride-Labs/stride/v25/x/icqoracle/types"; // TokenPrice stores latest price data for a token message TokenPrice { - // Token denom on Stride + // Base denom on Stride string base_denom = 1; // Quote denom on Stride string quote_denom = 2; - // Token denom on Osmosis - string osmosis_base_denom = 3; + // Decimals of base token, used for normalizing price feed from Osmosis + int64 base_denom_decimals = 3; + // Decimals of quote token, used for normalizing price feed from Osmosis + int64 quote_denom_decimals = 4; + // Base denom on Osmosis + string osmosis_base_denom = 5; // Quote denom on Osmosis - string osmosis_quote_denom = 4; + string osmosis_quote_denom = 6; // Pool ID on Osmosis - string osmosis_pool_id = 5; + string osmosis_pool_id = 7; // Spot price of base_denom denominated in quote_denom - string spot_price = 6 [ + string spot_price = 8 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // Last update timestamp - google.protobuf.Timestamp updated_at = 7 + google.protobuf.Timestamp updated_at = 9 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // Whether there is a spot price query currently in progress - bool query_in_progress = 8; + bool query_in_progress = 10; } // OracleParams stores global oracle parameters diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 413051c97b..624088031f 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -1,9 +1,9 @@ syntax = "proto3"; package stride.icqoracle; -import "cosmos/msg/v1/msg.proto"; import "amino/amino.proto"; import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; option go_package = "github.com/Stride-Labs/stride/v25/x/icqoracle/types"; @@ -32,12 +32,16 @@ message MsgRegisterTokenPriceQuery { string base_denom = 2; // Quote denom on Stride string quote_denom = 3; + // Decimals of base token, used for normalizing price feed from Osmosis + int64 base_denom_decimals = 4; + // Decimals of quote token, used for normalizing price feed from Osmosis + int64 quote_denom_decimals = 5; // Token denom on Osmosis - string osmosis_base_denom = 4; + string osmosis_base_denom = 6; // Quote denom on Osmosis - string osmosis_quote_denom = 5; + string osmosis_quote_denom = 7; // Pool ID on Osmosis - string osmosis_pool_id = 6; + string osmosis_pool_id = 8; } message MsgRegisterTokenPriceQueryResponse {} diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index 0f902642b5..9dea9d522a 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -99,8 +99,8 @@ type Auction struct { PaymentDenom string `protobuf:"bytes,4,opt,name=payment_denom,json=paymentDenom,proto3" json:"payment_denom,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,5,opt,name=enabled,proto3" json:"enabled,omitempty"` - // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle reported - // price) bids_floor_price = oracle_price * min_price_multiplier + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle price) + // bids_floor_price = oracle_price * min_price_multiplier MinPriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=min_price_multiplier,json=minPriceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_price_multiplier"` // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` @@ -197,39 +197,39 @@ func init() { proto.RegisterFile("stride/auction/auction.proto", fileDescriptor_ var fileDescriptor_739480caccbf7be9 = []byte{ // 525 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x3e, - 0x18, 0xc7, 0x9b, 0xdf, 0xaf, 0x6c, 0x9d, 0x37, 0xaa, 0x61, 0xb5, 0x92, 0xb7, 0x95, 0xac, 0xda, - 0x2e, 0x15, 0xd2, 0x12, 0x31, 0x38, 0x71, 0xeb, 0x5f, 0xa9, 0x62, 0x8c, 0x2a, 0x69, 0x91, 0xe0, - 0x40, 0xe4, 0x24, 0x26, 0xb3, 0x16, 0xdb, 0x51, 0xec, 0x4e, 0xf4, 0x5d, 0xf0, 0x62, 0x78, 0x05, - 0x9c, 0x76, 0x9c, 0x38, 0x21, 0x0e, 0x13, 0x6a, 0xdf, 0x08, 0x8a, 0x9d, 0x4e, 0x9b, 0xb8, 0xec, - 0x14, 0xfb, 0xfb, 0x7c, 0xbf, 0x9f, 0x58, 0xf6, 0xf3, 0x80, 0x96, 0x54, 0x39, 0x8d, 0x89, 0x8b, - 0xe7, 0x91, 0xa2, 0x82, 0xaf, 0xbf, 0x4e, 0x96, 0x0b, 0x25, 0x60, 0xdd, 0x54, 0x9d, 0x52, 0xdd, - 0xdf, 0x8b, 0x84, 0x64, 0x42, 0x06, 0xba, 0xea, 0x9a, 0x8d, 0xb1, 0xee, 0x37, 0x12, 0x91, 0x08, - 0xa3, 0x17, 0x2b, 0xa3, 0x1e, 0xd5, 0xc0, 0xc6, 0x04, 0xe7, 0x98, 0xc9, 0xa3, 0x1f, 0x55, 0xb0, - 0xd9, 0x35, 0x18, 0xe8, 0x82, 0xaa, 0x5a, 0x64, 0x04, 0x59, 0x6d, 0xab, 0x53, 0x3f, 0x3d, 0x70, - 0x1e, 0xfe, 0xc5, 0x29, 0x6d, 0xd3, 0x45, 0x46, 0x3c, 0x6d, 0x84, 0x10, 0x54, 0x39, 0x66, 0x04, - 0xfd, 0xd7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 0x21, 0x4c, 0x0b, 0x80, + 0x57, 0xe6, 0xe1, 0x07, 0x80, 0x0c, 0x7f, 0xfd, 0x42, 0x86, 0x2f, 0x45, 0x1a, 0x23, 0xf0, 0x18, + 0x76, 0x53, 0xc7, 0x7d, 0x93, 0xd6, 0x6c, 0x5f, 0xa4, 0xf1, 0x8b, 0x1e, 0xd8, 0xbe, 0xd7, 0x1c, + 0xb0, 0x05, 0x50, 0x77, 0xd6, 0x9f, 0x8e, 0xdf, 0x9f, 0x07, 0xd3, 0x8f, 0x93, 0x61, 0x30, 0x3b, + 0xf7, 0x27, 0xc3, 0xfe, 0x78, 0x34, 0x1e, 0x0e, 0x76, 0x2b, 0xb0, 0x09, 0x9e, 0x3d, 0xa8, 0x8e, + 0xfa, 0x23, 0x7f, 0xd7, 0xea, 0xbd, 0xbd, 0x5e, 0xda, 0xd6, 0xcd, 0xd2, 0xb6, 0xfe, 0x2c, 0x6d, + 0xeb, 0xdb, 0xca, 0xae, 0xdc, 0xac, 0xec, 0xca, 0xaf, 0x95, 0x5d, 0xf9, 0xf4, 0x32, 0xa1, 0xea, + 0x62, 0x1e, 0x3a, 0x91, 0x60, 0xae, 0xaf, 0x5b, 0xf2, 0xe4, 0x0c, 0x87, 0xd2, 0x2d, 0x47, 0xe4, + 0xea, 0xf4, 0xb5, 0xfb, 0xf5, 0x6e, 0x50, 0x8a, 0xbe, 0x94, 0xe1, 0x86, 0x6e, 0xf3, 0x57, 0x7f, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x67, 0xed, 0x43, 0x15, 0x47, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/auction/types/genesis.pb.go b/x/auction/types/genesis.pb.go index 57a415a4a2..c35aa20653 100644 --- a/x/auction/types/genesis.pb.go +++ b/x/auction/types/genesis.pb.go @@ -97,9 +97,9 @@ var fileDescriptor_94bb6618fc080329 = []byte{ 0x74, 0x7d, 0x8e, 0x10, 0x1a, 0xaa, 0x11, 0xae, 0xdc, 0xc9, 0xfb, 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, 0x0c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, - 0xf5, 0x83, 0xc1, 0x86, 0xe9, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0xfd, 0x53, 0x66, 0x64, 0xa2, + 0xf5, 0x83, 0xc1, 0x86, 0xe9, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0xfd, 0x53, 0x66, 0x64, 0xaa, 0x5f, 0x01, 0xf7, 0x55, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x53, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x1b, 0xbc, 0x9c, 0x7c, 0x38, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x15, 0x2c, 0x17, 0xd9, 0x38, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index 35dc30bbea..7ab7a3aea6 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -235,7 +235,7 @@ var fileDescriptor_8113674a9412675c = []byte{ // 422 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x4f, 0x6b, 0xdb, 0x30, 0x14, 0xb7, 0xb2, 0x6c, 0xc9, 0x34, 0xd8, 0x41, 0xcb, 0x36, 0x63, 0x86, 0x17, 0xbc, 0xff, 0x83, - 0x49, 0x24, 0x1b, 0x8c, 0x1d, 0x97, 0xc3, 0x76, 0x68, 0xa1, 0xad, 0x7b, 0xeb, 0xa1, 0x20, 0xa7, + 0x49, 0x24, 0x63, 0x8c, 0x1d, 0x97, 0xc3, 0x76, 0x68, 0xa1, 0xad, 0x7b, 0xeb, 0xa1, 0x20, 0xa7, 0xc2, 0x35, 0x34, 0x96, 0x13, 0xc9, 0xa1, 0xa1, 0xf4, 0xd2, 0x4f, 0x50, 0xe8, 0xb1, 0x5f, 0x28, 0xc7, 0x40, 0x2f, 0x3d, 0x95, 0x92, 0xf4, 0x43, 0xf4, 0x58, 0x2c, 0xc9, 0x69, 0x6c, 0x42, 0x72, 0xf2, 0xc3, 0xef, 0xf7, 0x4f, 0xef, 0x3d, 0xe8, 0x08, 0x39, 0x88, 0x0e, 0x18, 0xa1, 0x69, 0x57, @@ -258,8 +258,8 @@ var fileDescriptor_8113674a9412675c = []byte{ 0x4f, 0x74, 0x36, 0xc6, 0x53, 0x17, 0x4c, 0xa6, 0x2e, 0xb8, 0x9d, 0xba, 0xe0, 0x7c, 0xe6, 0x5a, 0x93, 0x99, 0x6b, 0x5d, 0xcf, 0x5c, 0x6b, 0xaf, 0x15, 0x46, 0xf2, 0x30, 0x0d, 0x70, 0x97, 0xf7, 0xc8, 0xae, 0x62, 0xff, 0xd8, 0xa4, 0x81, 0xc8, 0x95, 0x86, 0xed, 0x5f, 0xe4, 0x78, 0xae, 0x27, - 0x47, 0x09, 0x13, 0xc1, 0x33, 0x75, 0xc8, 0x3f, 0x1f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xad, 0x54, - 0x0c, 0x04, 0x74, 0x03, 0x00, 0x00, + 0x47, 0x09, 0x13, 0xc1, 0x33, 0x75, 0xc8, 0x3f, 0x1f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xc4, + 0x87, 0xa1, 0x74, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index 621f6639c2..a133ea8746 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -141,8 +141,8 @@ type MsgCreateAuction struct { PaymentDenom string `protobuf:"bytes,5,opt,name=payment_denom,json=paymentDenom,proto3" json:"payment_denom,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,6,opt,name=enabled,proto3" json:"enabled,omitempty"` - // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle reported - // price) bids_floor_price = oracle_price * min_price_multiplier + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle price) + // bids_floor_price = oracle_price * min_price_multiplier MinPriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=min_price_multiplier,json=minPriceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_price_multiplier"` // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` @@ -277,8 +277,8 @@ type MsgUpdateAuction struct { AuctionType AuctionType `protobuf:"varint,3,opt,name=auction_type,json=auctionType,proto3,enum=stride.auction.AuctionType" json:"auction_type,omitempty"` // Whether auction is active Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` - // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle reported - // price) bids_floor_price = oracle_price * min_price_multiplier + // Minimum price multiplier (e.g. 0.95 for 5% discount off the oracle price) + // bids_floor_price = oracle_price * min_price_multiplier MinPriceMultiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=min_price_multiplier,json=minPriceMultiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_price_multiplier"` // Minimum payment token bid amount MinBidAmount cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=min_bid_amount,json=minBidAmount,proto3,customtype=cosmossdk.io/math.Int" json:"min_bid_amount"` @@ -401,50 +401,50 @@ func init() { func init() { proto.RegisterFile("stride/auction/tx.proto", fileDescriptor_07b888fb549a7ca8) } var fileDescriptor_07b888fb549a7ca8 = []byte{ - // 687 bytes of a gzipped FileDescriptorProto + // 688 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3d, 0x4f, 0xdc, 0x4a, 0x14, 0x5d, 0x03, 0xbb, 0xc0, 0xf0, 0xa1, 0xf7, 0xcc, 0x22, 0xfc, 0x96, 0xf7, 0x16, 0xde, 0x6e, - 0x11, 0x84, 0x84, 0x1d, 0x48, 0x2a, 0x8a, 0x48, 0x2c, 0x34, 0x51, 0xd8, 0x04, 0x19, 0x68, 0x92, - 0x62, 0x35, 0xf6, 0x4c, 0xcc, 0x88, 0x9d, 0x19, 0xcb, 0x33, 0x8b, 0xd8, 0x2e, 0x4a, 0x49, 0x95, - 0x22, 0x7f, 0x22, 0x1d, 0x45, 0x7e, 0x40, 0x4a, 0x4a, 0x94, 0x2a, 0x4a, 0x81, 0x22, 0x28, 0xf8, - 0x1b, 0x91, 0x3d, 0xe3, 0xc5, 0x86, 0x55, 0x58, 0x29, 0x14, 0x69, 0x30, 0xf7, 0xde, 0x73, 0x8e, - 0xbd, 0xe7, 0x5c, 0xcd, 0x80, 0x39, 0x21, 0x23, 0x82, 0xb0, 0x03, 0x3b, 0xbe, 0x24, 0x9c, 0x39, - 0xf2, 0xd8, 0x0e, 0x23, 0x2e, 0xb9, 0x39, 0xad, 0x06, 0xb6, 0x1e, 0x54, 0xfe, 0x86, 0x94, 0x30, - 0xee, 0x24, 0x7f, 0x15, 0xa4, 0xf2, 0x8f, 0xcf, 0x05, 0xe5, 0xa2, 0x95, 0x54, 0x8e, 0x2a, 0xf4, - 0x68, 0x4e, 0x55, 0x0e, 0x15, 0x81, 0x73, 0xb4, 0x1a, 0x3f, 0xf4, 0xa0, 0x1c, 0xf0, 0x80, 0x2b, - 0x42, 0xfc, 0x9f, 0xee, 0xfe, 0x7b, 0xeb, 0x2b, 0xf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 0xc4, 0x76, 0x51, 0x4a, 0xaa, + 0x14, 0xf9, 0x13, 0xe9, 0x28, 0xf2, 0x03, 0x52, 0x52, 0xa2, 0x54, 0x51, 0x0a, 0x14, 0x41, 0xc1, + 0xdf, 0x88, 0xec, 0x19, 0x2f, 0x36, 0xac, 0xc2, 0x4a, 0xa1, 0x48, 0x83, 0xb9, 0xf7, 0x9e, 0x73, + 0xec, 0x3d, 0xe7, 0x6a, 0x06, 0xcc, 0x09, 0x19, 0x11, 0x84, 0x1d, 0xd8, 0xf1, 0x25, 0xe1, 0xcc, + 0x91, 0xc7, 0x76, 0x18, 0x71, 0xc9, 0xcd, 0x69, 0x35, 0xb0, 0xf5, 0xa0, 0xf2, 0x37, 0xa4, 0x84, + 0x71, 0x27, 0xf9, 0xab, 0x20, 0x95, 0x7f, 0x7c, 0x2e, 0x28, 0x17, 0xad, 0xa4, 0x72, 0x54, 0xa1, + 0x47, 0x73, 0xaa, 0x72, 0xa8, 0x08, 0x9c, 0xa3, 0xd5, 0xf8, 0xa1, 0x07, 0xe5, 0x80, 0x07, 0x5c, + 0x11, 0xe2, 0xff, 0x74, 0xf7, 0xdf, 0x5b, 0x5f, 0xa1, 0x9f, 0x6a, 0x5a, 0xfb, 0x34, 0x04, 0x26, + 0x9a, 0x22, 0xd8, 0x69, 0x43, 0x1f, 0x37, 0x08, 0x32, 0x1f, 0x83, 0x92, 0x47, 0x10, 0xc2, 0x91, + 0x65, 0x2c, 0x1a, 0x4b, 0xe3, 0x0d, 0xeb, 0xeb, 0xe7, 0x95, 0xb2, 0x7e, 0xfd, 0x06, 0x42, 0x11, + 0x16, 0x62, 0x57, 0x46, 0x84, 0x05, 0xae, 0xc6, 0x99, 0xff, 0x83, 0x49, 0x2d, 0xd9, 0x62, 0x90, + 0x62, 0x6b, 0x28, 0xe6, 0xb9, 0x13, 0xba, 0xf7, 0x12, 0x52, 0x6c, 0xbe, 0x02, 0x65, 0x81, 0xdb, + 0x6d, 0xc2, 0x82, 0x96,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 0xee, 0xfa, 0x74, 0xd9, 0x68, 0xbc, 0x38, 0xbb, 0xac, 0x1a, 0xe7, 0x97, 0x55, 0xe3, 0xc7, + 0x65, 0xd5, 0xf8, 0x70, 0x55, 0x2d, 0x9c, 0x5f, 0x55, 0x0b, 0xdf, 0xae, 0xaa, 0x85, 0xd7, 0xab, + 0x01, 0x91, 0x07, 0x1d, 0xcf, 0xf6, 0x39, 0x75, 0x76, 0x13, 0xd1, 0x95, 0x6d, 0xe8, 0x09, 0x47, + 0x5f, 0x58, 0x47, 0x6b, 0x4f, 0x9d, 0xe3, 0x9b, 0xcb, 0xb3, 0x1b, 0x62, 0xe1, 0x95, 0x92, 0x5b, + 0xeb, 0xc9, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x4b, 0x61, 0x3e, 0x5b, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go index c2dec76a24..6f0ea8cf9c 100644 --- a/x/icqoracle/client/cli/tx.go +++ b/x/icqoracle/client/cli/tx.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "strings" "github.com/cosmos/cosmos-sdk/client" @@ -33,13 +34,13 @@ func GetTxCmd() *cobra.Command { func CmdAddTokenPrice() *cobra.Command { cmd := &cobra.Command{ - Use: "add-token-price [base-denom] [quote-denom] [osmosis-pool-id] [osmosis-base-denom] [osmosis-quote-denom]", + Use: "add-token-price [base-denom] [quote-denom] [base-denom-decimals] [quote-denom-decimals] [osmosis-pool-id] [osmosis-base-denom] [osmosis-quote-denom]", Short: "Add a token to price tracking", Long: strings.TrimSpace( fmt.Sprintf(`Add a token to price tracking. Example: - $ %[1]s tx %[2]s add-token-price uosmo uatom 123 uosmo ibc/... --from admin + $ %[1]s tx %[2]s add-token-price uosmo uatom 6 6 123 uosmo ibc/... --from admin `, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(5), @@ -49,13 +50,25 @@ Example: return err } + baseDenomDecimls, err := strconv.ParseInt(args[2], 10, 64) + if err != nil { + return fmt.Errorf("Error parsing baseDenomDecmnals as int64: %w", err) + } + + quoteDenomDecimls, err := strconv.ParseInt(args[3], 10, 64) + if err != nil { + return fmt.Errorf("Error parsing quoteDenomDecmnals as int64: %w", err) + } + msg := types.NewMsgRegisterTokenPriceQuery( clientCtx.GetFromAddress().String(), args[0], args[1], - args[2], - args[3], + baseDenomDecimls, + quoteDenomDecimls, args[4], + args[5], + args[6], ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 157031a818..f2716443c4 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -148,10 +148,40 @@ func UnmarshalSpotPriceFromOsmosisClPool(tokenPrice types.TokenPrice, queryRespo return math.LegacyZeroDec(), err } - spotPrice, err := pool.SpotPrice(tokenPrice.OsmosisQuoteDenom, tokenPrice.OsmosisBaseDenom) + rawSpotPrice, err := pool.SpotPrice(tokenPrice.OsmosisQuoteDenom, tokenPrice.OsmosisBaseDenom) if err != nil { return math.LegacyZeroDec(), err } - return spotPrice, nil + return AdjustSpotPriceForDecimals( + rawSpotPrice, + tokenPrice.BaseDenomDecimals, + tokenPrice.QuoteDenomDecimals, + ), nil +} + +// AdjustSpotPriceForDecimals corrects the spot price to account for different decimal places between tokens +// Example: For BTC (8 decimals) / USDC (6 decimals): +// - If raw price is 1,000 USDC/BTC, we multiply by 10^(8-6) to get 100,000 USDC/BTC +func AdjustSpotPriceForDecimals(rawPrice math.LegacyDec, baseDecimals, quoteDecimals int64) math.LegacyDec { + decimalsDiff := baseDecimals - quoteDecimals + if decimalsDiff == 0 { + return rawPrice + } + + decimalAdjustmentExp := abs(decimalsDiff) + decimalAdjustment := math.LegacyNewDec(10).Power(decimalAdjustmentExp) + + if decimalsDiff > 0 { + return rawPrice.Mul(decimalAdjustment) + } else { + return rawPrice.Quo(decimalAdjustment) + } +} + +func abs(num int64) uint64 { + if num < 0 { + return uint64(-num) + } + return uint64(num) } diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index c0bac9dcc9..59c741743e 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -686,11 +686,13 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { baseTokenPrice := types.TokenPrice{ - BaseDenom: "uatom", - QuoteDenom: "uusdc", - OsmosisPoolId: "1", - OsmosisBaseDenom: "ibc/uatom", - OsmosisQuoteDenom: "uusdc", + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "uusdc", + BaseDenomDecimals: 6, + QuoteDenomDecimals: 6, } testCases := []struct { @@ -707,7 +709,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { expectedError: "proto: wrong wireType", }, { - name: "successful price calculation - base/quote order", + name: "successful price calculation with equal decimals", tokenPrice: baseTokenPrice, poolData: s.createMockPoolData( baseTokenPrice.OsmosisBaseDenom, @@ -716,22 +718,66 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { expectedPrice: math.LegacyNewDecWithPrec(15, 1), // 1.5 from mock pool data }, { - name: "successful price calculation - quote/base order", - tokenPrice: baseTokenPrice, + name: "successful price calculation with more base decimals", + tokenPrice: types.TokenPrice{ + BaseDenom: "satoshi", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/satoshi", + OsmosisQuoteDenom: "ibc/uusdc", + BaseDenomDecimals: 8, // BTC has 8 decimals + QuoteDenomDecimals: 6, // USDC has 6 decimals + }, poolData: s.createMockPoolData( - baseTokenPrice.OsmosisQuoteDenom, - baseTokenPrice.OsmosisBaseDenom, + "ibc/satoshi", + "ibc/uusdc", ), - expectedPrice: math.LegacyMustNewDecFromStr("0.666666666666666667"), // 1/1.5 from mock pool data + expectedPrice: math.LegacyNewDecWithPrec(15, 1).Mul(math.LegacyNewDec(100)), // 1.5 * 10^2 + }, + { + name: "successful price calculation with more quote decimals", + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "ibc/uusdc", + BaseDenomDecimals: 6, // ATOM has 6 decimals + QuoteDenomDecimals: 8, // Quote has 8 decimals + }, + poolData: s.createMockPoolData( + "ibc/uatom", + "ibc/uusdc", + ), + expectedPrice: math.LegacyNewDecWithPrec(15, 1).Quo(math.LegacyNewDec(100)), // 1.5 / 10^2 + }, + { + name: "price calculation with inverse pool ordering", + tokenPrice: types.TokenPrice{ + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "ibc/uusdc", + BaseDenomDecimals: 8, + QuoteDenomDecimals: 6, + }, + poolData: s.createMockPoolData( + "ibc/uusdc", + "ibc/uatom", + ), + expectedPrice: math.LegacyMustNewDecFromStr("0.666666666666666667").Mul(math.LegacyNewDec(100)), // (1/1.5) * 10^2 }, { name: "different denom ordering in pool", tokenPrice: types.TokenPrice{ - BaseDenom: "uatom", - QuoteDenom: "uusdc", - OsmosisPoolId: "1", - OsmosisBaseDenom: "ibc/uatom", - OsmosisQuoteDenom: "different_denom", // Different from pool data + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + OsmosisBaseDenom: "ibc/uatom", + OsmosisQuoteDenom: "different_denom", + BaseDenomDecimals: 6, + QuoteDenomDecimals: 6, }, poolData: s.createMockPoolData( "ibc/uatom", @@ -750,14 +796,97 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { s.Require().Contains(err.Error(), tc.expectedError) } else { s.Require().NoError(err) - // Use InDelta for floating point comparison with small tolerance s.Require().InDelta( tc.expectedPrice.MustFloat64(), spotPrice.MustFloat64(), - 0.01, + 0.000001, "expected price %v, got %v", tc.expectedPrice, spotPrice, ) } }) } } + +func (s *KeeperTestSuite) TestAdjustSpotPriceForDecimals() { + testCases := []struct { + name string + rawPrice math.LegacyDec + baseDecimals int64 + quoteDecimals int64 + expectedPrice math.LegacyDec + }{ + { + name: "equal decimals", + rawPrice: math.LegacyNewDec(1000), + baseDecimals: 6, + quoteDecimals: 6, + expectedPrice: math.LegacyNewDec(1000), + }, + { + name: "base has more decimals", + rawPrice: math.LegacyNewDec(1000), + baseDecimals: 8, // BTC + quoteDecimals: 6, // USDC + expectedPrice: math.LegacyNewDec(100000), // 1000 * 10^(8-6) + }, + { + name: "quote has more decimals", + rawPrice: math.LegacyNewDec(1000), + baseDecimals: 6, // USDC + quoteDecimals: 8, // BTC + expectedPrice: math.LegacyNewDec(10), // 1000 / 10^(8-6) + }, + { + name: "large base decimal", + rawPrice: math.LegacyNewDec(1), + baseDecimals: 18, // ETH + quoteDecimals: 6, // USDC + expectedPrice: math.LegacyNewDec(1000000000000), // 1 * 10^(18-6) + }, + { + name: "large quote decimal", + rawPrice: math.LegacyNewDec(1000000000000), + baseDecimals: 6, // USDC + quoteDecimals: 18, // ETH + expectedPrice: math.LegacyNewDec(1), // 1000000000000 / 10^(18-6) + }, + { + name: "zero base decimals", + rawPrice: math.LegacyNewDec(100), + baseDecimals: 0, + quoteDecimals: 6, + expectedPrice: math.LegacyNewDec(1).Quo(math.LegacyNewDec(1000000)), // 100 / 10^6 + }, + { + name: "zero quote decimals", + rawPrice: math.LegacyNewDec(100), + baseDecimals: 6, + quoteDecimals: 0, + expectedPrice: math.LegacyNewDec(100000000), // 100 * 10^6 + }, + { + name: "both zero decimals", + rawPrice: math.LegacyNewDec(100), + baseDecimals: 0, + quoteDecimals: 0, + expectedPrice: math.LegacyNewDec(100), + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + adjustedPrice := keeper.AdjustSpotPriceForDecimals( + tc.rawPrice, + tc.baseDecimals, + tc.quoteDecimals, + ) + + s.Require().InDelta( + tc.expectedPrice.MustFloat64(), + adjustedPrice.MustFloat64(), + 0.0001, + "expected price %v, got %v", tc.expectedPrice, adjustedPrice, + ) + }) + } +} diff --git a/x/icqoracle/types/genesis.go b/x/icqoracle/types/genesis.go index bddce61281..8f941ca270 100644 --- a/x/icqoracle/types/genesis.go +++ b/x/icqoracle/types/genesis.go @@ -17,6 +17,8 @@ func (gs GenesisState) Validate() error { err := ValidateTokenPriceQueryParams( tokenPrice.BaseDenom, tokenPrice.QuoteDenom, + tokenPrice.BaseDenomDecimals, + tokenPrice.QuoteDenomDecimals, tokenPrice.OsmosisPoolId, tokenPrice.OsmosisBaseDenom, tokenPrice.OsmosisQuoteDenom, diff --git a/x/icqoracle/types/genesis.pb.go b/x/icqoracle/types/genesis.pb.go index 9ab1a5af1a..8c80d63e1c 100644 --- a/x/icqoracle/types/genesis.pb.go +++ b/x/icqoracle/types/genesis.pb.go @@ -99,8 +99,8 @@ var fileDescriptor_a0cfd8712dde4d4a = []byte{ 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xe3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0x60, 0xb0, 0xa1, 0xba, 0x3e, 0x89, 0x49, 0xc5, 0xfa, 0x50, 0x2f, - 0x96, 0x19, 0x99, 0xe8, 0x57, 0x20, 0x79, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, - 0x4b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x21, 0x4a, 0x5a, 0xfa, 0x51, 0x01, 0x00, 0x00, + 0x96, 0x19, 0x99, 0xea, 0x57, 0x20, 0x79, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, + 0x4b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x60, 0x51, 0xd6, 0x94, 0x51, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 75b384f326..33df8ff06c 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -30,22 +30,26 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // TokenPrice stores latest price data for a token type TokenPrice struct { - // Token denom on Stride + // Base denom on Stride BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` // Quote denom on Stride QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` - // Token denom on Osmosis - OsmosisBaseDenom string `protobuf:"bytes,3,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` + // Decimals of base token, used for normalizing price feed from Osmosis + BaseDenomDecimals int64 `protobuf:"varint,3,opt,name=base_denom_decimals,json=baseDenomDecimals,proto3" json:"base_denom_decimals,omitempty"` + // Decimals of quote token, used for normalizing price feed from Osmosis + QuoteDenomDecimals int64 `protobuf:"varint,4,opt,name=quote_denom_decimals,json=quoteDenomDecimals,proto3" json:"quote_denom_decimals,omitempty"` + // Base denom on Osmosis + OsmosisBaseDenom string `protobuf:"bytes,5,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` // Quote denom on Osmosis - OsmosisQuoteDenom string `protobuf:"bytes,4,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` + OsmosisQuoteDenom string `protobuf:"bytes,6,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,5,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + OsmosisPoolId string `protobuf:"bytes,7,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` // Spot price of base_denom denominated in quote_denom - SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` + SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` // Last update timestamp - UpdatedAt time.Time `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + UpdatedAt time.Time `protobuf:"bytes,9,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` // Whether there is a spot price query currently in progress - QueryInProgress bool `protobuf:"varint,8,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` + QueryInProgress bool `protobuf:"varint,10,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` } func (m *TokenPrice) Reset() { *m = TokenPrice{} } @@ -95,6 +99,20 @@ func (m *TokenPrice) GetQuoteDenom() string { return "" } +func (m *TokenPrice) GetBaseDenomDecimals() int64 { + if m != nil { + return m.BaseDenomDecimals + } + return 0 +} + +func (m *TokenPrice) GetQuoteDenomDecimals() int64 { + if m != nil { + return m.QuoteDenomDecimals + } + return 0 +} + func (m *TokenPrice) GetOsmosisBaseDenom() string { if m != nil { return m.OsmosisBaseDenom @@ -220,46 +238,48 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 617 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x1b, 0xd6, 0x8d, 0xd5, 0xd3, 0xd8, 0x96, 0xf1, 0xa7, 0x94, 0x51, 0x57, 0x99, 0x84, - 0x26, 0xc4, 0x12, 0x69, 0x83, 0x03, 0xdc, 0xc8, 0x86, 0x50, 0xa5, 0x21, 0x95, 0x6c, 0x1c, 0xe0, - 0x12, 0xb9, 0x8e, 0xc9, 0xac, 0x35, 0x71, 0x1a, 0x3b, 0xd3, 0xfa, 0x09, 0xe0, 0xb8, 0x3b, 0x5f, - 0x68, 0xc7, 0x1d, 0x11, 0x07, 0x83, 0xb6, 0x5b, 0x8f, 0xfd, 0x04, 0x28, 0x76, 0xd2, 0x95, 0x52, - 0xed, 0x96, 0x3c, 0xbf, 0xc7, 0xef, 0x63, 0xbf, 0xaf, 0x65, 0xd0, 0xe2, 0x22, 0xa5, 0x01, 0x71, - 0x28, 0xee, 0xb3, 0x14, 0xe1, 0xde, 0xc4, 0x97, 0x9d, 0xa4, 0x4c, 0x30, 0x73, 0x55, 0x3b, 0xec, - 0xb1, 0xde, 0xb8, 0x1f, 0xb2, 0x90, 0x29, 0xe8, 0xe4, 0x5f, 0xda, 0xd7, 0x80, 0x21, 0x63, 0x61, - 0x8f, 0x38, 0xea, 0xaf, 0x9b, 0x7d, 0x75, 0x04, 0x8d, 0x08, 0x17, 0x28, 0x4a, 0xb4, 0xc1, 0xfa, - 0x36, 0x07, 0xc0, 0x11, 0x3b, 0x21, 0x71, 0x27, 0xa5, 0x98, 0x98, 0x4f, 0x01, 0xe8, 0x22, 0x4e, - 0xfc, 0x80, 0xc4, 0x2c, 0xaa, 0x1b, 0x2d, 0x63, 0xab, 0xe6, 0xd5, 0x72, 0x65, 0x3f, 0x17, 0x4c, - 0x08, 0x96, 0x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0x5c, 0x35, 0x8d, 0xcb, 0xab, 0xa6, 0xf1, 0xe7, 0xaa, 0x69, 0x9c, 0x5f, 0x37, 0x2b, 0x97, 0xd7, - 0xcd, 0xca, 0xcf, 0xeb, 0x66, 0xe5, 0xcb, 0x6e, 0x48, 0xc5, 0x71, 0xd6, 0xb5, 0x31, 0x8b, 0x9c, - 0x43, 0xf5, 0x2a, 0x6c, 0x1f, 0xa0, 0x2e, 0x77, 0x8a, 0x37, 0xe4, 0x74, 0xe7, 0xa5, 0x73, 0x36, - 0xf1, 0x92, 0x88, 0x41, 0x42, 0x78, 0x77, 0x41, 0xdd, 0xe0, 0xdd, 0xbf, 0x01, 0x00, 0x00, 0xff, - 0xff, 0x4d, 0x8e, 0x4f, 0xd6, 0x6a, 0x04, 0x00, 0x00, + // 654 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0xc7, 0x1b, 0xd6, 0x8d, 0xd5, 0xd3, 0xd8, 0x9a, 0x0d, 0x28, 0x65, 0xd4, 0x55, 0x26, 0xa1, + 0x0a, 0xb1, 0x04, 0x6d, 0xda, 0x01, 0x6e, 0x64, 0x43, 0xa8, 0xd2, 0x90, 0x4a, 0x36, 0x0e, 0x70, + 0x89, 0x5c, 0xc7, 0x64, 0xd6, 0x92, 0x38, 0x8d, 0xdd, 0x69, 0xfd, 0x06, 0x1c, 0x77, 0xe7, 0x0b, + 0xed, 0xb8, 0x23, 0xe2, 0x10, 0xd0, 0x76, 0xa2, 0xc7, 0x7e, 0x02, 0x14, 0xe7, 0xa5, 0xa1, 0x54, + 0xbb, 0xb9, 0xff, 0xdf, 0xff, 0x79, 0xe9, 0xf3, 0x38, 0x06, 0x6d, 0x2e, 0x22, 0xea, 0x10, 0x83, + 0xe2, 0x01, 0x8b, 0x10, 0xf6, 0x4a, 0x27, 0x3d, 0x8c, 0x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(m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -290,7 +310,7 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x40 + dAtA[i] = 0x50 } n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) if err1 != nil { @@ -299,7 +319,7 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintIcqoracle(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x4a { size := m.SpotPrice.Size() i -= size @@ -309,27 +329,37 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintIcqoracle(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x42 if len(m.OsmosisPoolId) > 0 { i -= len(m.OsmosisPoolId) copy(dAtA[i:], m.OsmosisPoolId) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisPoolId))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a } if len(m.OsmosisQuoteDenom) > 0 { i -= len(m.OsmosisQuoteDenom) copy(dAtA[i:], m.OsmosisQuoteDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisQuoteDenom))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 } if len(m.OsmosisBaseDenom) > 0 { i -= len(m.OsmosisBaseDenom) copy(dAtA[i:], m.OsmosisBaseDenom) i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisBaseDenom))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a + } + if m.QuoteDenomDecimals != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.QuoteDenomDecimals)) + i-- + dAtA[i] = 0x20 + } + if m.BaseDenomDecimals != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.BaseDenomDecimals)) + i-- + dAtA[i] = 0x18 } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) @@ -425,6 +455,12 @@ func (m *TokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) } + if m.BaseDenomDecimals != 0 { + n += 1 + sovIcqoracle(uint64(m.BaseDenomDecimals)) + } + if m.QuoteDenomDecimals != 0 { + n += 1 + sovIcqoracle(uint64(m.QuoteDenomDecimals)) + } l = len(m.OsmosisBaseDenom) if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) @@ -573,6 +609,44 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenomDecimals", wireType) + } + m.BaseDenomDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BaseDenomDecimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenomDecimals", wireType) + } + m.QuoteDenomDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuoteDenomDecimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisBaseDenom", wireType) } @@ -604,7 +678,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.OsmosisBaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisQuoteDenom", wireType) } @@ -636,7 +710,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } @@ -668,7 +742,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", wireType) } @@ -702,7 +776,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) } @@ -735,7 +809,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", wireType) } diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index fe5d71c4d8..15738a3f0b 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -28,14 +28,25 @@ var ( // MsgClaim // ---------------------------------------------- -func NewMsgRegisterTokenPriceQuery(admin, baseDenom, quoteDenom, poolId, osmosisBaseDenom, osmosisQuoteDenom string) *MsgRegisterTokenPriceQuery { +func NewMsgRegisterTokenPriceQuery( + admin string, + baseDenom string, + quoteDenom string, + baseDecimals int64, + quoteDecimals int64, + poolId string, + osmosisBaseDenom string, + osmosisQuoteDenom string, +) *MsgRegisterTokenPriceQuery { return &MsgRegisterTokenPriceQuery{ - Admin: admin, - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, - OsmosisPoolId: poolId, - OsmosisBaseDenom: osmosisBaseDenom, - OsmosisQuoteDenom: osmosisQuoteDenom, + Admin: admin, + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + BaseDenomDecimals: baseDecimals, + QuoteDenomDecimals: quoteDecimals, + OsmosisBaseDenom: osmosisBaseDenom, + OsmosisQuoteDenom: osmosisQuoteDenom, + OsmosisPoolId: poolId, } } @@ -67,6 +78,8 @@ func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { return ValidateTokenPriceQueryParams( msg.BaseDenom, msg.QuoteDenom, + msg.BaseDenomDecimals, + msg.QuoteDenomDecimals, msg.OsmosisPoolId, msg.OsmosisBaseDenom, msg.OsmosisQuoteDenom, diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index f1628335b0..096480b3e5 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -431,43 +431,43 @@ var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ // 622 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, 0x10, 0x8e, 0xfb, 0x13, 0xd4, 0x09, 0x07, 0xb4, 0x54, 0xc4, 0x58, 0xa9, 0x13, 0x99, 0xb6, 0x94, - 0x4a, 0xf5, 0xaa, 0x29, 0xf4, 0x01, 0x42, 0x28, 0x42, 0xa2, 0x52, 0x1a, 0x38, 0x71, 0x20, 0xda, - 0x38, 0x2b, 0x63, 0x35, 0xf1, 0x3a, 0x5e, 0xa7, 0xd0, 0x6b, 0x0f, 0x9c, 0x91, 0x78, 0x0b, 0x2e, - 0xbc, 0x02, 0xc7, 0x1e, 0x2b, 0x71, 0x41, 0x1c, 0x2a, 0x94, 0xf0, 0x20, 0xc8, 0xbb, 0xeb, 0xfc, - 0xd4, 0x09, 0x09, 0x12, 0xa7, 0x6c, 0x66, 0xbe, 0x99, 0xf9, 0xe6, 0xdb, 0xcf, 0x0b, 0x05, 0x1e, - 0x85, 0x5e, 0x8b, 0x62, 0xcf, 0xe9, 0xb2, 0x90, 0x38, 0x6d, 0x8a, 0xbb, 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 0xb8, + 0xf0, 0x0a, 0x1c, 0x7b, 0xac, 0xc4, 0x05, 0x71, 0xa8, 0x50, 0xc2, 0x83, 0x20, 0xef, 0xae, 0xf3, + 0x53, 0x27, 0x24, 0x48, 0x9c, 0xb2, 0x99, 0xf9, 0x66, 0xe6, 0x9b, 0x6f, 0x3f, 0x2f, 0x14, 0x78, + 0x14, 0x7a, 0x2d, 0x8a, 0x3d, 0xa7, 0xcb, 0x42, 0xe2, 0xb4, 0x29, 0xee, 0xf6, 0x68, 0x78, 0x61, + 0x07, 0x21, 0x8b, 0x18, 0xba, 0x27, 0xb3, 0xf6, 0x30, 0x6b, 0x94, 0x52, 0xf8, 0xe1, 0x49, 0xd6, + 0x18, 0xeb, 0x2e, 0x73, 0x99, 0x38, 0xe2, 0xf8, 0xa4, 0xa2, 0x05, 0x97, 0x31, 0xb7, 0x4d, 0x31, + 0x09, 0x3c, 0x4c, 0x7c, 0x9f, 0x45, 0x24, 0xf2, 0x98, 0xcf, 0x55, 0x76, 0xd7, 0x61, 0xbc, 0xc3, + 0x38, 0x6e, 0x12, 0xae, 0x08, 0xe0, 0xf3, 0xfd, 0x26, 0x8d, 0xc8, 0x3e, 0x0e, 0x88, 0xeb, 0xf9, + 0x02, 0x2c, 0xb1, 0x56, 0x17, 0x1e, 0x9c, 0xc6, 0x88, 0xd7, 0xec, 0x8c, 0xfa, 0xb5, 0xd0, 0x73, + 0x68, 0x9d, 0x76, 0x7b, 0x94, 0x47, 0x68, 0x03, 0x20, 0x6e, 0xd0, 0x68, 0x51, 0x9f, 0x75, 0x74, + 0xad, 0xa4, 0xed, 0xac, 0xd5, 0xd7, 0xe2, 0x48, 0x35, 0x0e, 0xa0, 0x22, 0xe4, 0xba, 0x3d, 0x16, + 0x25, 0xf9, 0x25, 0x91, 0x07, 0x11, 0x92, 0x80, 0x3c, 0xdc, 0x09, 0x18, 0x6b, 0x37, 0xbc, 0x96, + 0xbe, 0x2c, 0x92, 0xd9, 0xf8, 0xef, 0x8b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0xff, 0xff, 0xcc, 0xd0, 0xaa, 0x7e, 0x69, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index 8dee348ce7..e16cfa869c 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -38,12 +38,16 @@ type MsgRegisterTokenPriceQuery struct { BaseDenom string `protobuf:"bytes,2,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` // Quote denom on Stride QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + // Decimals of base token, used for normalizing price feed from Osmosis + BaseDenomDecimals int64 `protobuf:"varint,4,opt,name=base_denom_decimals,json=baseDenomDecimals,proto3" json:"base_denom_decimals,omitempty"` + // Decimals of quote token, used for normalizing price feed from Osmosis + QuoteDenomDecimals int64 `protobuf:"varint,5,opt,name=quote_denom_decimals,json=quoteDenomDecimals,proto3" json:"quote_denom_decimals,omitempty"` // Token denom on Osmosis - OsmosisBaseDenom string `protobuf:"bytes,4,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` + OsmosisBaseDenom string `protobuf:"bytes,6,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` // Quote denom on Osmosis - OsmosisQuoteDenom string `protobuf:"bytes,5,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` + OsmosisQuoteDenom string `protobuf:"bytes,7,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,6,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + OsmosisPoolId string `protobuf:"bytes,8,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } func (m *MsgRegisterTokenPriceQuery) Reset() { *m = MsgRegisterTokenPriceQuery{} } @@ -100,6 +104,20 @@ func (m *MsgRegisterTokenPriceQuery) GetQuoteDenom() string { return "" } +func (m *MsgRegisterTokenPriceQuery) GetBaseDenomDecimals() int64 { + if m != nil { + return m.BaseDenomDecimals + } + return 0 +} + +func (m *MsgRegisterTokenPriceQuery) GetQuoteDenomDecimals() int64 { + if m != nil { + return m.QuoteDenomDecimals + } + return 0 +} + func (m *MsgRegisterTokenPriceQuery) GetOsmosisBaseDenom() string { if m != nil { return m.OsmosisBaseDenom @@ -276,37 +294,39 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 466 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x94, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x37, 0xdb, 0x6e, 0xa1, 0xaf, 0x88, 0x6d, 0x54, 0x9a, 0x06, 0x8c, 0x25, 0x14, 0x91, - 0xa5, 0xcd, 0xd0, 0xdd, 0x9e, 0xbc, 0xb9, 0x78, 0x11, 0x5c, 0x68, 0x53, 0x4f, 0x5e, 0x42, 0xfe, - 0x0c, 0x71, 0x70, 0x93, 0x37, 0x9d, 0xc9, 0xae, 0xed, 0x41, 0x10, 0xf1, 0xe4, 0xc9, 0x8f, 0xb2, - 0x07, 0xbf, 0x83, 0x1e, 0x8b, 0x27, 0x8f, 0xb2, 0x8b, 0xec, 0xd7, 0x90, 0xcc, 0x24, 0xed, 0xba, - 0x24, 0xa0, 0x27, 0x2f, 0xbb, 0xcc, 0xf3, 0xfc, 0xe6, 0x49, 0xe6, 0x99, 0xc9, 0xc0, 0xae, 0xc8, - 0x39, 0x8b, 0x28, 0x61, 0xe1, 0x39, 0x72, 0x3f, 0x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x7f, - 0x58, 0x4c, 0xbb, 0x6a, 0x45, 0x9f, 0x16, 0xd3, 0xee, 0xfe, 0xcd, 0x86, 0x34, 0x57, 0x65, 0xef, - 0x83, 0xdd, 0xec, 0xba, 0x54, 0x64, 0x98, 0x0a, 0x6a, 0xff, 0xd2, 0xc0, 0x90, 0x58, 0x82, 0x13, - 0xfa, 0xbf, 0xdb, 0xae, 0xe9, 0x63, 0xbd, 0xae, 0x8f, 0xa3, 0x3f, 0xfb, 0xb0, 0x57, 0xfa, 0xa8, - 0x59, 0x8a, 0x6d, 0xc3, 0x5e, 0x93, 0x57, 0x75, 0xd1, 0xfb, 0xd8, 0x86, 0xb5, 0xa1, 0x88, 0xf5, - 0x77, 0xb0, 0xd3, 0x74, 0xfe, 0x0e, 0x9c, 0xd5, 0x83, 0xef, 0x34, 0x97, 0x6c, 0x1e, 0xff, 0x0b, - 0x5d, 0xbd, 0x86, 0xfe, 0x16, 0xee, 0xd7, 0x6f, 0x47, 0xb7, 0x21, 0xae, 0x86, 0x35, 0x7b, 0x7f, - 0xcf, 0x56, 0x0f, 0x36, 0x3b, 0xef, 0x17, 0xd3, 0xae, 0x36, 0x18, 0x7e, 0x9b, 0x59, 0xda, 0xd5, - 0xcc, 0xd2, 0x7e, 0xce, 0x2c, 0xed, 0xf3, 0xdc, 0x6a, 0x5d, 0xcd, 0xad, 0xd6, 0x8f, 0xb9, 0xd5, - 0x7a, 0xd5, 0x8f, 0x59, 0xfe, 0x7a, 0x1c, 0x38, 0x21, 0x26, 0xe4, 0x4c, 0xc6, 0x1f, 0xbe, 0xf0, - 0x03, 0x41, 0xca, 0x7b, 0x62, 0xd2, 0x3b, 0x26, 0x17, 0xcb, 0xb7, 0xc5, 0x65, 0x46, 0x45, 0xb0, - 0x21, 0x3f, 0xec, 0xfe, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x44, 0x3a, 0x25, 0x4e, 0x04, - 0x00, 0x00, + // 505 bytes of a gzipped FileDescriptorProto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 0x3c, + 0x8e, 0xff, 0xce, 0xc3, 0x58, 0xc9, 0xa3, 0xe0, 0x55, 0x0c, 0x03, 0x1a, 0x65, 0x58, 0x96, 0x45, + 0xeb, 0xd3, 0x1a, 0x54, 0xbb, 0xe8, 0x93, 0xf7, 0xb0, 0x5b, 0xf6, 0x85, 0x1f, 0x9a, 0xab, 0xbf, + 0x96, 0x59, 0x1e, 0xb2, 0xf6, 0xe4, 0x7f, 0xd8, 0x99, 0x0d, 0xf2, 0x0e, 0xee, 0x17, 0x8f, 0xa3, + 0x59, 0x22, 0x57, 0xc0, 0xd5, 0x5a, 0xff, 0xce, 0xcd, 0x1e, 0xac, 0xd5, 0x3e, 0xcc, 0xc6, 0x4d, + 0xa5, 0xd3, 0xfd, 0x3e, 0xd1, 0x95, 0xeb, 0x89, 0xae, 0xfc, 0x9a, 0xe8, 0xca, 0x97, 0xa9, 0x5e, + 0xb9, 0x9e, 0xea, 0x95, 0x9f, 0x53, 0xbd, 0xf2, 0xba, 0xed, 0xf3, 0xf8, 0xcd, 0xb0, 0x67, 0xba, + 0x22, 0xa0, 0xe7, 0x52, 0xfe, 0xe8, 0xa5, 0xd3, 0x43, 0x9a, 0x6e, 0xa2, 0x51, 0xeb, 0x29, 0xbd, + 0x5c, 0xde, 0x47, 0x57, 0x03, 0x86, 0xbd, 0x0d, 0xb9, 0x3a, 0xda, 0x7f, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x7b, 0x76, 0x0a, 0x6f, 0xb0, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -454,21 +474,31 @@ func (m *MsgRegisterTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, err copy(dAtA[i:], m.OsmosisPoolId) i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisPoolId))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x42 } if len(m.OsmosisQuoteDenom) > 0 { i -= len(m.OsmosisQuoteDenom) copy(dAtA[i:], m.OsmosisQuoteDenom) i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisQuoteDenom))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a } if len(m.OsmosisBaseDenom) > 0 { i -= len(m.OsmosisBaseDenom) copy(dAtA[i:], m.OsmosisBaseDenom) i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisBaseDenom))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 + } + if m.QuoteDenomDecimals != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.QuoteDenomDecimals)) + i-- + dAtA[i] = 0x28 + } + if m.BaseDenomDecimals != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.BaseDenomDecimals)) + i-- + dAtA[i] = 0x20 } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) @@ -620,6 +650,12 @@ func (m *MsgRegisterTokenPriceQuery) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.BaseDenomDecimals != 0 { + n += 1 + sovTx(uint64(m.BaseDenomDecimals)) + } + if m.QuoteDenomDecimals != 0 { + n += 1 + sovTx(uint64(m.QuoteDenomDecimals)) + } l = len(m.OsmosisBaseDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -810,6 +846,44 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenomDecimals", wireType) + } + m.BaseDenomDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BaseDenomDecimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenomDecimals", wireType) + } + m.QuoteDenomDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuoteDenomDecimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisBaseDenom", wireType) } @@ -841,7 +915,7 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { } m.OsmosisBaseDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisQuoteDenom", wireType) } @@ -873,7 +947,7 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { } m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } diff --git a/x/icqoracle/types/validate.go b/x/icqoracle/types/validate.go index a84a72984c..e0bc68d252 100644 --- a/x/icqoracle/types/validate.go +++ b/x/icqoracle/types/validate.go @@ -5,13 +5,27 @@ import ( "strconv" ) -func ValidateTokenPriceQueryParams(baseDenom, quoteDenom, osmosisPoolId, osmosisBaseDenom, osmosisQuoteDenom string) error { +func ValidateTokenPriceQueryParams( + baseDenom string, + quoteDenom string, + baseDenomDecimals int64, + quoteDenomDecimals int64, + osmosisPoolId string, + osmosisBaseDenom string, + osmosisQuoteDenom string, +) error { if baseDenom == "" { return errors.New("base-denom must be specified") } if quoteDenom == "" { return errors.New("quote-denom must be specified") } + if baseDenomDecimals <= 0 { + return errors.New("base-denom-decimals must be bigger than 0") + } + if quoteDenomDecimals <= 0 { + return errors.New("quote-denom-decimals must be bigger than 0") + } if _, err := strconv.ParseUint(osmosisPoolId, 10, 64); err != nil { return errors.New("osmosis-pool-id must be uint64") } diff --git a/x/strdburner/types/genesis.pb.go b/x/strdburner/types/genesis.pb.go index dd7693f273..9fb1397c3a 100644 --- a/x/strdburner/types/genesis.pb.go +++ b/x/strdburner/types/genesis.pb.go @@ -83,8 +83,8 @@ var fileDescriptor_003ecc60d66895bb = []byte{ 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x26, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc1, 0x60, 0xa7, 0xea, 0xfa, 0x24, 0x26, 0x15, 0xeb, 0x43, 0xfd, 0x55, - 0x66, 0x64, 0xa2, 0x5f, 0x81, 0xec, 0xbb, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x9b, - 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x11, 0x3a, 0xa0, 0xff, 0x00, 0x00, 0x00, + 0x66, 0x64, 0xaa, 0x5f, 0x81, 0xec, 0xbb, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x9b, + 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xec, 0x8f, 0xa1, 0xff, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/strdburner/types/query.pb.go b/x/strdburner/types/query.pb.go index 43b0c31a11..ee154cb9c3 100644 --- a/x/strdburner/types/query.pb.go +++ b/x/strdburner/types/query.pb.go @@ -226,8 +226,8 @@ var fileDescriptor_76c45869caa19016 = []byte{ 0x77, 0xf2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0x60, 0xb0, 0x21, 0xba, 0x3e, 0x89, 0x49, - 0xc5, 0x30, 0x03, 0xcb, 0x8c, 0x4c, 0xf4, 0x2b, 0x50, 0x8c, 0xad, 0x2c, 0x48, 0x2d, 0x4e, 0x62, - 0x03, 0xa7, 0x4a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0x0c, 0x0a, 0x2f, 0x18, 0x03, + 0xc5, 0x30, 0x03, 0xcb, 0x8c, 0x4c, 0xf5, 0x2b, 0x50, 0x8c, 0xad, 0x2c, 0x48, 0x2d, 0x4e, 0x62, + 0x03, 0xa7, 0x4a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xf1, 0xbf, 0x2e, 0x18, 0x03, 0x00, 0x00, } From c720da3d24fbd15cdbc292d68327dbaa4b51b546 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:29:57 +0200 Subject: [PATCH 094/115] Fix new modules for v26 store upgrades after merge Updates store upgrades configuration for v26 to include three new modules: - ICQ Oracle - STRD Burner - Auction --- app/upgrades.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 4c50ddbe54..242290aaff 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -43,14 +43,17 @@ import ( v8 "github.com/Stride-Labs/stride/v25/app/upgrades/v8" v9 "github.com/Stride-Labs/stride/v25/app/upgrades/v9" airdroptypes "github.com/Stride-Labs/stride/v25/x/airdrop/types" + auctiontypes "github.com/Stride-Labs/stride/v25/x/auction/types" autopilottypes "github.com/Stride-Labs/stride/v25/x/autopilot/types" claimtypes "github.com/Stride-Labs/stride/v25/x/claim/types" icacallbacktypes "github.com/Stride-Labs/stride/v25/x/icacallbacks/types" icaoracletypes "github.com/Stride-Labs/stride/v25/x/icaoracle/types" + icqoracletypes "github.com/Stride-Labs/stride/v25/x/icqoracle/types" recordtypes "github.com/Stride-Labs/stride/v25/x/records/types" stakedymtypes "github.com/Stride-Labs/stride/v25/x/stakedym/types" stakeibctypes "github.com/Stride-Labs/stride/v25/x/stakeibc/types" staketiatypes "github.com/Stride-Labs/stride/v25/x/staketia/types" + strdburnertypes "github.com/Stride-Labs/stride/v25/x/strdburner/types" ) func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) { @@ -399,9 +402,9 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) { storeUpgrades = &storetypes.StoreUpgrades{ Added: []string{ibcwasmtypes.ModuleName, airdroptypes.ModuleName}, } - case "v25": + case "v26": storeUpgrades = &storetypes.StoreUpgrades{ - Added: []string{}, + Added: []string{icqoracletypes.ModuleName, strdburnertypes.ModuleName, auctiontypes.ModuleName}, } } From c8e0e1a817a28076d24d2efb2113a5aa065095a0 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:33:29 +0200 Subject: [PATCH 095/115] group icq callback registration in app.go makes it easier to keep track of --- app/app.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index ae736af022..8988aea745 100644 --- a/app/app.go +++ b/app/app.go @@ -787,12 +787,6 @@ func NewStrideApp( ) icqOracleModule := icqoracle.NewAppModule(appCodec, app.ICQOracleKeeper) - // Register ICQ callbacks - err = app.InterchainqueryKeeper.SetCallbackHandler(icqoracletypes.ModuleName, app.ICQOracleKeeper.ICQCallbackHandler()) - if err != nil { - return nil - } - app.AuctionKeeper = *auctionkeeper.NewKeeper( appCodec, keys[auctiontypes.StoreKey], @@ -831,6 +825,10 @@ func NewStrideApp( if err != nil { return nil } + err = app.InterchainqueryKeeper.SetCallbackHandler(icqoracletypes.ModuleName, app.ICQOracleKeeper.ICQCallbackHandler()) + if err != nil { + return nil + } app.EpochsKeeper = *epochsKeeper.SetHooks( epochsmoduletypes.NewMultiEpochHooks( From 5b956a8151eaffb38494a90a2e83fa3a4b5c704b Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:41:12 +0200 Subject: [PATCH 096/115] rm osmo from default dockernet host chains --- dockernet/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockernet/config.sh b/dockernet/config.sh index 4a19783850..0f6ed5ece6 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -35,7 +35,7 @@ ACCESSORY_CHAINS=() if [[ "${ALL_HOST_CHAINS:-false}" == "true" ]]; then HOST_CHAINS=(GAIA EVMOS HOST) elif [[ "${#HOST_CHAINS[@]}" == "0" ]]; then - HOST_CHAINS=(GAIA OSMO) + HOST_CHAINS=(GAIA) fi REWARD_CONVERTER_HOST_ZONE=${HOST_CHAINS[0]} From 5b470c214ecc2e6934f412ea84d504ca347d8562 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:41:51 +0200 Subject: [PATCH 097/115] rm ts-tests --- dockernet/ts-tests/.npmrc | 1 - dockernet/ts-tests/.prettierrc.json | 8 - dockernet/ts-tests/README.md | 37 - dockernet/ts-tests/package.json | 34 - dockernet/ts-tests/pnpm-lock.yaml | 4068 -------------------------- dockernet/ts-tests/test/main.test.ts | 268 -- dockernet/ts-tests/test/utils.ts | 33 - dockernet/ts-tests/vitest.config.ts | 26 - 8 files changed, 4475 deletions(-) delete mode 100644 dockernet/ts-tests/.npmrc delete mode 100644 dockernet/ts-tests/.prettierrc.json delete mode 100644 dockernet/ts-tests/README.md delete mode 100644 dockernet/ts-tests/package.json delete mode 100644 dockernet/ts-tests/pnpm-lock.yaml delete mode 100644 dockernet/ts-tests/test/main.test.ts delete mode 100644 dockernet/ts-tests/test/utils.ts delete mode 100644 dockernet/ts-tests/vitest.config.ts diff --git a/dockernet/ts-tests/.npmrc b/dockernet/ts-tests/.npmrc deleted file mode 100644 index 0a60c47597..0000000000 --- a/dockernet/ts-tests/.npmrc +++ /dev/null @@ -1 +0,0 @@ -save-prefix='' \ No newline at end of file diff --git a/dockernet/ts-tests/.prettierrc.json b/dockernet/ts-tests/.prettierrc.json deleted file mode 100644 index e6d10890cb..0000000000 --- a/dockernet/ts-tests/.prettierrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "trailingComma": "all", - "tabWidth": 2, - "useTabs": false, - "semi": true, - "singleQuote": false, - "printWidth": 80 -} diff --git a/dockernet/ts-tests/README.md b/dockernet/ts-tests/README.md deleted file mode 100644 index 05faa81347..0000000000 --- a/dockernet/ts-tests/README.md +++ /dev/null @@ -1,37 +0,0 @@ -### running the tests - -```bash -# build stride locally and run dokcernet -(cd ../.. && make sync && make start-docker build=sgro) - -# install deps -pnpm i - -# run tests -pnpm test -``` - -IMPORTANT: `@cosmjs/*` dependencies must match the versions used by stridejs. To get those versions, run e.g. `pnpm why @cosmjs/amino`. - -### debugging (vscode) - -- open command palette: `Shift + Command + P (Mac) / Ctrl + Shift + P (Windows/Linux)` -- run the `Debug: Create JavaScript Debug Terminal` command -- set breakpoints -- run `pnpm test` - -### test new protobufs - -- go to https://github.com/Stride-Labs/stridejs - - remove `/dist` from `.gitignore` - - update the config in `scripts/clone_repos.ts` to point to the new `stride/cosmos-sdk/ibc-go` version - - run `pnpm i` - - run `pnpm codegen` - - run `pnpm build` - - run `git commit...` - - run `git push` - - get the current `stridejs` commit using `git rev-parse HEAD` -- in the integration tests (this project): - - update the `stridejs` dependency commit hash in `package.json` - - `pnpm i` - - `pnpm test` diff --git a/dockernet/ts-tests/package.json b/dockernet/ts-tests/package.json deleted file mode 100644 index 3dfef7a28a..0000000000 --- a/dockernet/ts-tests/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "stride-integration-tests", - "version": "1.0.0", - "type": "module", - "description": "integration tests for stride chain", - "scripts": { - "test": "NODE_OPTIONS=--conditions=node vitest run", - "test-watch": "NODE_OPTIONS=--conditions=node vitest watch" - }, - "keywords": [ - "wow", - "much", - "liquidity" - ], - "author": "Stride Labs", - "license": "ISC", - "dependencies": { - "@cosmjs/amino": "0.32.4", - "@cosmjs/encoding": "0.32.4", - "@cosmjs/math": "0.32.4", - "@cosmjs/proto-signing": "0.32.4", - "@cosmjs/stargate": "0.32.4", - "@cosmjs/tendermint-rpc": "0.32.4", - "@cosmology/lcd": "0.13.4", - "@noble/hashes": "1.4.0", - "bech32": "2.0.0", - "jest": "29.7.0", - "prettier": "3.3.3", - "stridejs": "github:Stride-Labs/stridejs#e949e35", - "typescript": "5.5.3", - "vitest": "2.0.3" - }, - "packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a" -} diff --git a/dockernet/ts-tests/pnpm-lock.yaml b/dockernet/ts-tests/pnpm-lock.yaml deleted file mode 100644 index 79354fd853..0000000000 --- a/dockernet/ts-tests/pnpm-lock.yaml +++ /dev/null @@ -1,4068 +0,0 @@ -lockfileVersion: '9.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -importers: - - .: - dependencies: - '@cosmjs/amino': - specifier: 0.32.4 - version: 0.32.4 - '@cosmjs/encoding': - specifier: 0.32.4 - version: 0.32.4 - '@cosmjs/math': - specifier: 0.32.4 - version: 0.32.4 - '@cosmjs/proto-signing': - specifier: 0.32.4 - version: 0.32.4 - '@cosmjs/stargate': - specifier: 0.32.4 - version: 0.32.4 - '@cosmjs/tendermint-rpc': - specifier: 0.32.4 - version: 0.32.4 - '@cosmology/lcd': - specifier: 0.13.4 - version: 0.13.4 - '@noble/hashes': - specifier: 1.4.0 - version: 1.4.0 - bech32: - specifier: 2.0.0 - version: 2.0.0 - jest: - specifier: 29.7.0 - version: 29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - prettier: - specifier: 3.3.3 - version: 3.3.3 - stridejs: - specifier: github:Stride-Labs/stridejs#e949e35 - version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35 - typescript: - specifier: 5.5.3 - version: 5.5.3 - vitest: - specifier: 2.0.3 - version: 2.0.3(@types/node@20.14.11)(terser@5.31.3) - -packages: - - '@ampproject/remapping@2.3.0': - resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} - engines: {node: '>=6.0.0'} - - '@babel/code-frame@7.24.7': - resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} - engines: {node: '>=6.9.0'} - - '@babel/compat-data@7.24.9': - resolution: {integrity: sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==} - engines: {node: '>=6.9.0'} - - '@babel/core@7.24.9': - resolution: {integrity: sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==} - engines: {node: '>=6.9.0'} - - '@babel/generator@7.24.10': - resolution: {integrity: sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==} - engines: {node: '>=6.9.0'} - - '@babel/helper-compilation-targets@7.24.8': - resolution: {integrity: sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==} - engines: {node: '>=6.9.0'} - - '@babel/helper-environment-visitor@7.24.7': - resolution: {integrity: sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==} - engines: {node: '>=6.9.0'} - - '@babel/helper-function-name@7.24.7': - resolution: {integrity: sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==} - engines: {node: '>=6.9.0'} - - '@babel/helper-hoist-variables@7.24.7': - resolution: {integrity: sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==} - engines: {node: '>=6.9.0'} - - '@babel/helper-module-imports@7.24.7': - resolution: {integrity: sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==} - engines: {node: '>=6.9.0'} - - '@babel/helper-module-transforms@7.24.9': - resolution: {integrity: sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - - '@babel/helper-plugin-utils@7.24.8': - resolution: {integrity: sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==} - engines: {node: '>=6.9.0'} - - '@babel/helper-simple-access@7.24.7': - resolution: {integrity: sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==} - engines: {node: '>=6.9.0'} - - '@babel/helper-split-export-declaration@7.24.7': - resolution: {integrity: sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==} - engines: {node: '>=6.9.0'} - - '@babel/helper-string-parser@7.24.8': - resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} - engines: {node: '>=6.9.0'} - - '@babel/helper-validator-identifier@7.24.7': - resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} - engines: {node: '>=6.9.0'} - - '@babel/helper-validator-option@7.24.8': - resolution: {integrity: sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==} - engines: {node: '>=6.9.0'} - - '@babel/helpers@7.24.8': - resolution: {integrity: sha512-gV2265Nkcz7weJJfvDoAEVzC1e2OTDpkGbEsebse8koXUJUXPsCMi7sRo/+SPMuMZ9MtUPnGwITTnQnU5YjyaQ==} - engines: {node: '>=6.9.0'} - - '@babel/highlight@7.24.7': - resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} - engines: {node: '>=6.9.0'} - - '@babel/parser@7.24.8': - resolution: {integrity: sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==} - engines: {node: '>=6.0.0'} - hasBin: true - - '@babel/plugin-syntax-async-generators@7.8.4': - resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-bigint@7.8.3': - resolution: {integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-class-properties@7.12.13': - resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-import-meta@7.10.4': - resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-json-strings@7.8.3': - resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-jsx@7.24.7': - resolution: {integrity: sha512-6ddciUPe/mpMnOKv/U+RSd2vvVy+Yw/JfBB0ZHYjEZt9NLHmCUylNYlsbqCCS1Bffjlb0fCwC9Vqz+sBz6PsiQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-logical-assignment-operators@7.10.4': - resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3': - resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-numeric-separator@7.10.4': - resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-object-rest-spread@7.8.3': - resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-optional-catch-binding@7.8.3': - resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-optional-chaining@7.8.3': - resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-top-level-await@7.14.5': - resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/plugin-syntax-typescript@7.24.7': - resolution: {integrity: sha512-c/+fVeJBB0FeKsFvwytYiUD+LBvhHjGSI0g446PRGdSVGZLRNArBUno2PETbAly3tpiNAQR5XaZ+JslxkotsbA==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - - '@babel/template@7.24.7': - resolution: {integrity: sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==} - engines: {node: '>=6.9.0'} - - '@babel/traverse@7.24.8': - resolution: {integrity: sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==} - engines: {node: '>=6.9.0'} - - '@babel/types@7.24.9': - resolution: {integrity: sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==} - engines: {node: '>=6.9.0'} - - '@bcoe/v8-coverage@0.2.3': - resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} - - '@confio/ics23@0.6.8': - resolution: {integrity: sha512-wB6uo+3A50m0sW/EWcU64xpV/8wShZ6bMTa7pF8eYsTrSkQA7oLUIJcs/wb8g4y2Oyq701BaGiO6n/ak5WXO1w==} - - '@cosmjs/amino@0.32.4': - resolution: {integrity: sha512-zKYOt6hPy8obIFtLie/xtygCkH9ZROiQ12UHfKsOkWaZfPQUvVbtgmu6R4Kn1tFLI/SRkw7eqhaogmW/3NYu/Q==} - - '@cosmjs/crypto@0.32.4': - resolution: {integrity: sha512-zicjGU051LF1V9v7bp8p7ovq+VyC91xlaHdsFOTo2oVry3KQikp8L/81RkXmUIT8FxMwdx1T7DmFwVQikcSDIw==} - - '@cosmjs/encoding@0.32.4': - resolution: {integrity: sha512-tjvaEy6ZGxJchiizzTn7HVRiyTg1i4CObRRaTRPknm5EalE13SV+TCHq38gIDfyUeden4fCuaBVEdBR5+ti7Hw==} - - '@cosmjs/json-rpc@0.32.4': - resolution: {integrity: sha512-/jt4mBl7nYzfJ2J/VJ+r19c92mUKF0Lt0JxM3MXEJl7wlwW5haHAWtzRujHkyYMXOwIR+gBqT2S0vntXVBRyhQ==} - - '@cosmjs/math@0.32.4': - resolution: {integrity: sha512-++dqq2TJkoB8zsPVYCvrt88oJWsy1vMOuSOKcdlnXuOA/ASheTJuYy4+oZlTQ3Fr8eALDLGGPhJI02W2HyAQaw==} - - '@cosmjs/proto-signing@0.32.4': - resolution: {integrity: sha512-QdyQDbezvdRI4xxSlyM1rSVBO2st5sqtbEIl3IX03uJ7YiZIQHyv6vaHVf1V4mapusCqguiHJzm4N4gsFdLBbQ==} - - '@cosmjs/socket@0.32.4': - resolution: {integrity: sha512-davcyYziBhkzfXQTu1l5NrpDYv0K9GekZCC9apBRvL1dvMc9F/ygM7iemHjUA+z8tJkxKxrt/YPjJ6XNHzLrkw==} - - '@cosmjs/stargate@0.32.4': - resolution: {integrity: sha512-usj08LxBSsPRq9sbpCeVdyLx2guEcOHfJS9mHGCLCXpdAPEIEQEtWLDpEUc0LEhWOx6+k/ChXTc5NpFkdrtGUQ==} - - '@cosmjs/stream@0.32.4': - resolution: {integrity: sha512-Gih++NYHEiP+oyD4jNEUxU9antoC0pFSg+33Hpp0JlHwH0wXhtD3OOKnzSfDB7OIoEbrzLJUpEjOgpCp5Z+W3A==} - - '@cosmjs/tendermint-rpc@0.32.4': - resolution: {integrity: sha512-MWvUUno+4bCb/LmlMIErLypXxy7ckUuzEmpufYYYd9wgbdCXaTaO08SZzyFM5PI8UJ/0S2AmUrgWhldlbxO8mw==} - - '@cosmjs/utils@0.32.4': - resolution: {integrity: sha512-D1Yc+Zy8oL/hkUkFUL/bwxvuDBzRGpc4cF7/SkdhxX4iHpSLgdOuTt1mhCh9+kl6NQREy9t7SYZ6xeW5gFe60w==} - - '@cosmology/lcd@0.13.4': - resolution: {integrity: sha512-llClHHHjOCie9PxnXUOxvMcWi0aVjmzkRXM6IBBXluOczRFFog23rPPfrWZPeT30dIX1SGklp0Fek28O76BkvQ==} - - '@cspotcode/source-map-support@0.8.1': - resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} - engines: {node: '>=12'} - - '@esbuild/aix-ppc64@0.21.5': - resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [aix] - - '@esbuild/android-arm64@0.21.5': - resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - - '@esbuild/android-arm@0.21.5': - resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - - '@esbuild/android-x64@0.21.5': - resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - - '@esbuild/darwin-arm64@0.21.5': - resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - - '@esbuild/darwin-x64@0.21.5': - resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - - '@esbuild/freebsd-arm64@0.21.5': - resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - - '@esbuild/freebsd-x64@0.21.5': - resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - - '@esbuild/linux-arm64@0.21.5': - resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - - '@esbuild/linux-arm@0.21.5': - resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - - '@esbuild/linux-ia32@0.21.5': - resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - - '@esbuild/linux-loong64@0.21.5': - resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - - '@esbuild/linux-mips64el@0.21.5': - resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - - '@esbuild/linux-ppc64@0.21.5': - resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - - '@esbuild/linux-riscv64@0.21.5': - resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - - '@esbuild/linux-s390x@0.21.5': - resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - - '@esbuild/linux-x64@0.21.5': - resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - - '@esbuild/netbsd-x64@0.21.5': - resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - - '@esbuild/openbsd-x64@0.21.5': - resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - - '@esbuild/sunos-x64@0.21.5': - resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - - '@esbuild/win32-arm64@0.21.5': - resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - - '@esbuild/win32-ia32@0.21.5': - resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - - '@esbuild/win32-x64@0.21.5': - resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - - '@istanbuljs/load-nyc-config@1.1.0': - resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} - engines: {node: '>=8'} - - '@istanbuljs/schema@0.1.3': - resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} - engines: {node: '>=8'} - - '@jest/console@29.7.0': - resolution: {integrity: sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/core@29.7.0': - resolution: {integrity: sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - - '@jest/environment@29.7.0': - resolution: {integrity: sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/expect-utils@29.7.0': - resolution: {integrity: sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/expect@29.7.0': - resolution: {integrity: sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/fake-timers@29.7.0': - resolution: {integrity: sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/globals@29.7.0': - resolution: {integrity: sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/reporters@29.7.0': - resolution: {integrity: sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - - '@jest/schemas@29.6.3': - resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/source-map@29.6.3': - resolution: {integrity: sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/test-result@29.7.0': - resolution: {integrity: sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/test-sequencer@29.7.0': - resolution: {integrity: sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/transform@29.7.0': - resolution: {integrity: sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jest/types@29.6.3': - resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - '@jridgewell/gen-mapping@0.3.5': - resolution: {integrity: sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==} - engines: {node: '>=6.0.0'} - - '@jridgewell/resolve-uri@3.1.2': - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} - - '@jridgewell/set-array@1.2.1': - resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} - engines: {node: '>=6.0.0'} - - '@jridgewell/source-map@0.3.6': - resolution: {integrity: sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==} - - '@jridgewell/sourcemap-codec@1.5.0': - resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - - '@jridgewell/trace-mapping@0.3.25': - resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - - '@jridgewell/trace-mapping@0.3.9': - resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} - - '@noble/hashes@1.4.0': - resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} - engines: {node: '>= 16'} - - '@protobufjs/aspromise@1.1.2': - resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} - - '@protobufjs/base64@1.1.2': - resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} - - '@protobufjs/codegen@2.0.4': - resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} - - '@protobufjs/eventemitter@1.1.0': - resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} - - '@protobufjs/fetch@1.1.0': - resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} - - '@protobufjs/float@1.0.2': - resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} - - '@protobufjs/inquire@1.1.0': - resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} - - '@protobufjs/path@1.1.2': - resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} - - '@protobufjs/pool@1.1.0': - resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} - - '@protobufjs/utf8@1.1.0': - resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} - - '@rollup/rollup-android-arm-eabi@4.18.1': - resolution: {integrity: sha512-lncuC4aHicncmbORnx+dUaAgzee9cm/PbIqgWz1PpXuwc+sa1Ct83tnqUDy/GFKleLiN7ZIeytM6KJ4cAn1SxA==} - cpu: [arm] - os: [android] - - '@rollup/rollup-android-arm64@4.18.1': - resolution: {integrity: sha512-F/tkdw0WSs4ojqz5Ovrw5r9odqzFjb5LIgHdHZG65dFI1lWTWRVy32KDJLKRISHgJvqUeUhdIvy43fX41znyDg==} - cpu: [arm64] - os: [android] - - '@rollup/rollup-darwin-arm64@4.18.1': - resolution: {integrity: sha512-vk+ma8iC1ebje/ahpxpnrfVQJibTMyHdWpOGZ3JpQ7Mgn/3QNHmPq7YwjZbIE7km73dH5M1e6MRRsnEBW7v5CQ==} - cpu: [arm64] - os: [darwin] - - '@rollup/rollup-darwin-x64@4.18.1': - resolution: {integrity: sha512-IgpzXKauRe1Tafcej9STjSSuG0Ghu/xGYH+qG6JwsAUxXrnkvNHcq/NL6nz1+jzvWAnQkuAJ4uIwGB48K9OCGA==} - cpu: [x64] - os: [darwin] - - '@rollup/rollup-linux-arm-gnueabihf@4.18.1': - resolution: {integrity: sha512-P9bSiAUnSSM7EmyRK+e5wgpqai86QOSv8BwvkGjLwYuOpaeomiZWifEos517CwbG+aZl1T4clSE1YqqH2JRs+g==} - cpu: [arm] - os: [linux] - - '@rollup/rollup-linux-arm-musleabihf@4.18.1': - resolution: {integrity: sha512-5RnjpACoxtS+aWOI1dURKno11d7krfpGDEn19jI8BuWmSBbUC4ytIADfROM1FZrFhQPSoP+KEa3NlEScznBTyQ==} - cpu: [arm] - os: [linux] - - '@rollup/rollup-linux-arm64-gnu@4.18.1': - resolution: {integrity: sha512-8mwmGD668m8WaGbthrEYZ9CBmPug2QPGWxhJxh/vCgBjro5o96gL04WLlg5BA233OCWLqERy4YUzX3bJGXaJgQ==} - cpu: [arm64] - os: [linux] - - '@rollup/rollup-linux-arm64-musl@4.18.1': - resolution: {integrity: sha512-dJX9u4r4bqInMGOAQoGYdwDP8lQiisWb9et+T84l2WXk41yEej8v2iGKodmdKimT8cTAYt0jFb+UEBxnPkbXEQ==} - cpu: [arm64] - os: [linux] - - '@rollup/rollup-linux-powerpc64le-gnu@4.18.1': - resolution: {integrity: sha512-V72cXdTl4EI0x6FNmho4D502sy7ed+LuVW6Ym8aI6DRQ9hQZdp5sj0a2usYOlqvFBNKQnLQGwmYnujo2HvjCxQ==} - cpu: [ppc64] - os: [linux] - - '@rollup/rollup-linux-riscv64-gnu@4.18.1': - resolution: {integrity: sha512-f+pJih7sxoKmbjghrM2RkWo2WHUW8UbfxIQiWo5yeCaCM0TveMEuAzKJte4QskBp1TIinpnRcxkquY+4WuY/tg==} - cpu: [riscv64] - os: [linux] - - '@rollup/rollup-linux-s390x-gnu@4.18.1': - resolution: {integrity: sha512-qb1hMMT3Fr/Qz1OKovCuUM11MUNLUuHeBC2DPPAWUYYUAOFWaxInaTwTQmc7Fl5La7DShTEpmYwgdt2hG+4TEg==} - cpu: [s390x] - os: [linux] - - '@rollup/rollup-linux-x64-gnu@4.18.1': - resolution: {integrity: sha512-7O5u/p6oKUFYjRbZkL2FLbwsyoJAjyeXHCU3O4ndvzg2OFO2GinFPSJFGbiwFDaCFc+k7gs9CF243PwdPQFh5g==} - cpu: [x64] - os: [linux] - - '@rollup/rollup-linux-x64-musl@4.18.1': - resolution: {integrity: sha512-pDLkYITdYrH/9Cv/Vlj8HppDuLMDUBmgsM0+N+xLtFd18aXgM9Nyqupb/Uw+HeidhfYg2lD6CXvz6CjoVOaKjQ==} - cpu: [x64] - os: [linux] - - '@rollup/rollup-win32-arm64-msvc@4.18.1': - resolution: {integrity: sha512-W2ZNI323O/8pJdBGil1oCauuCzmVd9lDmWBBqxYZcOqWD6aWqJtVBQ1dFrF4dYpZPks6F+xCZHfzG5hYlSHZ6g==} - cpu: [arm64] - os: [win32] - - '@rollup/rollup-win32-ia32-msvc@4.18.1': - resolution: {integrity: sha512-ELfEX1/+eGZYMaCIbK4jqLxO1gyTSOIlZr6pbC4SRYFaSIDVKOnZNMdoZ+ON0mrFDp4+H5MhwNC1H/AhE3zQLg==} - cpu: [ia32] - os: [win32] - - '@rollup/rollup-win32-x64-msvc@4.18.1': - resolution: {integrity: sha512-yjk2MAkQmoaPYCSu35RLJ62+dz358nE83VfTePJRp8CG7aMg25mEJYpXFiD+NcevhX8LxD5OP5tktPXnXN7GDw==} - cpu: [x64] - os: [win32] - - '@sinclair/typebox@0.27.8': - resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} - - '@sinonjs/commons@3.0.1': - resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} - - '@sinonjs/fake-timers@10.3.0': - resolution: {integrity: sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==} - - '@tsconfig/node10@1.0.11': - resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} - - '@tsconfig/node12@1.0.11': - resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - - '@tsconfig/node14@1.0.3': - resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - - '@tsconfig/node16@1.0.4': - resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} - - '@types/babel__core@7.20.5': - resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} - - '@types/babel__generator@7.6.8': - resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==} - - '@types/babel__template@7.4.4': - resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} - - '@types/babel__traverse@7.20.6': - resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} - - '@types/estree@1.0.5': - resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} - - '@types/graceful-fs@4.1.9': - resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} - - '@types/istanbul-lib-coverage@2.0.6': - resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} - - '@types/istanbul-lib-report@3.0.3': - resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} - - '@types/istanbul-reports@3.0.4': - resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} - - '@types/long@4.0.2': - resolution: {integrity: sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==} - - '@types/node@20.14.11': - resolution: {integrity: sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==} - - '@types/stack-utils@2.0.3': - resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} - - '@types/yargs-parser@21.0.3': - resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} - - '@types/yargs@17.0.32': - resolution: {integrity: sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==} - - '@vitest/expect@2.0.3': - resolution: {integrity: sha512-X6AepoOYePM0lDNUPsGXTxgXZAl3EXd0GYe/MZyVE4HzkUqyUVC6S3PrY5mClDJ6/7/7vALLMV3+xD/Ko60Hqg==} - - '@vitest/pretty-format@2.0.3': - resolution: {integrity: sha512-URM4GLsB2xD37nnTyvf6kfObFafxmycCL8un3OC9gaCs5cti2u+5rJdIflZ2fUJUen4NbvF6jCufwViAFLvz1g==} - - '@vitest/runner@2.0.3': - resolution: {integrity: sha512-EmSP4mcjYhAcuBWwqgpjR3FYVeiA4ROzRunqKltWjBfLNs1tnMLtF+qtgd5ClTwkDP6/DGlKJTNa6WxNK0bNYQ==} - - '@vitest/snapshot@2.0.3': - resolution: {integrity: sha512-6OyA6v65Oe3tTzoSuRPcU6kh9m+mPL1vQ2jDlPdn9IQoUxl8rXhBnfICNOC+vwxWY684Vt5UPgtcA2aPFBb6wg==} - - '@vitest/spy@2.0.3': - resolution: {integrity: sha512-sfqyAw/ypOXlaj4S+w8689qKM1OyPOqnonqOc9T91DsoHbfN5mU7FdifWWv3MtQFf0lEUstEwR9L/q/M390C+A==} - - '@vitest/utils@2.0.3': - resolution: {integrity: sha512-c/UdELMuHitQbbc/EVctlBaxoYAwQPQdSNwv7z/vHyBKy2edYZaFgptE27BRueZB7eW8po+cllotMNTDpL3HWg==} - - acorn-walk@8.3.3: - resolution: {integrity: sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==} - engines: {node: '>=0.4.0'} - - acorn@8.12.1: - resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} - engines: {node: '>=0.4.0'} - hasBin: true - - ansi-escapes@4.3.2: - resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} - engines: {node: '>=8'} - - ansi-regex@5.0.1: - resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} - engines: {node: '>=8'} - - ansi-styles@3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} - - ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - - ansi-styles@5.2.0: - resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} - engines: {node: '>=10'} - - anymatch@3.1.3: - resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} - engines: {node: '>= 8'} - - arg@4.1.3: - resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} - - argparse@1.0.10: - resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} - - assertion-error@2.0.1: - resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} - engines: {node: '>=12'} - - asynckit@0.4.0: - resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} - - axios@1.6.0: - resolution: {integrity: sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==} - - babel-jest@29.7.0: - resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@babel/core': ^7.8.0 - - babel-plugin-istanbul@6.1.1: - resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} - engines: {node: '>=8'} - - babel-plugin-jest-hoist@29.6.3: - resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - babel-preset-current-node-syntax@1.0.1: - resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==} - peerDependencies: - '@babel/core': ^7.0.0 - - babel-preset-jest@29.6.3: - resolution: {integrity: sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@babel/core': ^7.0.0 - - balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - - base64-js@1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - - bech32@1.1.4: - resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} - - bech32@2.0.0: - resolution: {integrity: sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==} - - bn.js@4.12.0: - resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} - - bn.js@5.2.1: - resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} - - brace-expansion@1.1.11: - resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} - - braces@3.0.3: - resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} - engines: {node: '>=8'} - - brorand@1.1.0: - resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - - browserslist@4.23.2: - resolution: {integrity: sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==} - engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} - hasBin: true - - bser@2.1.1: - resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} - - buffer-from@1.1.2: - resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - - cac@6.7.14: - resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} - engines: {node: '>=8'} - - callsites@3.1.0: - resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} - engines: {node: '>=6'} - - camelcase@5.3.1: - resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} - engines: {node: '>=6'} - - camelcase@6.3.0: - resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} - engines: {node: '>=10'} - - caniuse-lite@1.0.30001642: - resolution: {integrity: sha512-3XQ0DoRgLijXJErLSl+bLnJ+Et4KqV1PY6JJBGAFlsNsz31zeAIncyeZfLCabHK/jtSh+671RM9YMldxjUPZtA==} - - chai@5.1.1: - resolution: {integrity: sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==} - engines: {node: '>=12'} - - chalk@2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} - - chalk@4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} - - char-regex@1.0.2: - resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} - engines: {node: '>=10'} - - check-error@2.1.1: - resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} - engines: {node: '>= 16'} - - ci-info@3.9.0: - resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} - engines: {node: '>=8'} - - cjs-module-lexer@1.3.1: - resolution: {integrity: sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==} - - cliui@8.0.1: - resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} - engines: {node: '>=12'} - - co@4.6.0: - resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} - engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} - - collect-v8-coverage@1.0.2: - resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==} - - color-convert@1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - - color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - - color-name@1.1.3: - resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - - color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - - combined-stream@1.0.8: - resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} - engines: {node: '>= 0.8'} - - commander@2.20.3: - resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} - - concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - - convert-source-map@2.0.0: - resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} - - cosmjs-types@0.9.0: - resolution: {integrity: sha512-MN/yUe6mkJwHnCFfsNPeCfXVhyxHYW6c/xDUzrSbBycYzw++XvWDMJArXp2pLdgD6FQ8DW79vkPjeNKVrXaHeQ==} - - create-jest@29.7.0: - resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - hasBin: true - - create-require@1.1.1: - resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - - cross-spawn@7.0.3: - resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} - engines: {node: '>= 8'} - - debug@4.3.5: - resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - - dedent@1.5.3: - resolution: {integrity: sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==} - peerDependencies: - babel-plugin-macros: ^3.1.0 - peerDependenciesMeta: - babel-plugin-macros: - optional: true - - deep-eql@5.0.2: - resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} - engines: {node: '>=6'} - - deepmerge@4.3.1: - resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} - engines: {node: '>=0.10.0'} - - define-data-property@1.1.4: - resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} - engines: {node: '>= 0.4'} - - define-properties@1.2.1: - resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} - engines: {node: '>= 0.4'} - - delayed-stream@1.0.0: - resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} - engines: {node: '>=0.4.0'} - - detect-newline@3.1.0: - resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} - engines: {node: '>=8'} - - diff-sequences@29.6.3: - resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - diff@4.0.2: - resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} - engines: {node: '>=0.3.1'} - - electron-to-chromium@1.4.829: - resolution: {integrity: sha512-5qp1N2POAfW0u1qGAxXEtz6P7bO1m6gpZr5hdf5ve6lxpLM7MpiM4jIPz7xcrNlClQMafbyUDDWjlIQZ1Mw0Rw==} - - elliptic@6.5.6: - resolution: {integrity: sha512-mpzdtpeCLuS3BmE3pO3Cpp5bbjlOPY2Q0PgoF+Od1XZrHLYI28Xe3ossCmYCQt11FQKEYd9+PF8jymTvtWJSHQ==} - - emittery@0.13.1: - resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} - engines: {node: '>=12'} - - emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - - error-ex@1.3.2: - resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} - - es-define-property@1.0.0: - resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} - engines: {node: '>= 0.4'} - - es-errors@1.3.0: - resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} - engines: {node: '>= 0.4'} - - esbuild@0.21.5: - resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==} - engines: {node: '>=12'} - hasBin: true - - escalade@3.1.2: - resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} - engines: {node: '>=6'} - - escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - - escape-string-regexp@2.0.0: - resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} - engines: {node: '>=8'} - - esprima@4.0.1: - resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} - engines: {node: '>=4'} - hasBin: true - - estree-walker@3.0.3: - resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} - - execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - - execa@8.0.1: - resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} - engines: {node: '>=16.17'} - - exit@0.1.2: - resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} - engines: {node: '>= 0.8.0'} - - expect@29.7.0: - resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - fast-json-stable-stringify@2.1.0: - resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - - fb-watchman@2.0.2: - resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==} - - fill-range@7.1.1: - resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} - engines: {node: '>=8'} - - find-up@4.1.0: - resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} - engines: {node: '>=8'} - - follow-redirects@1.15.6: - resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} - engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true - - form-data@4.0.0: - resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} - engines: {node: '>= 6'} - - fs.realpath@1.0.0: - resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - - fsevents@2.3.3: - resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - - function-bind@1.1.2: - resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} - - gensync@1.0.0-beta.2: - resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} - engines: {node: '>=6.9.0'} - - get-caller-file@2.0.5: - resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} - engines: {node: 6.* || 8.* || >= 10.*} - - get-func-name@2.0.2: - resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} - - get-intrinsic@1.2.4: - resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==} - engines: {node: '>= 0.4'} - - get-package-type@0.1.0: - resolution: {integrity: sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==} - engines: {node: '>=8.0.0'} - - get-stream@6.0.1: - resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} - engines: {node: '>=10'} - - get-stream@8.0.1: - resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} - engines: {node: '>=16'} - - glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Glob versions prior to v9 are no longer supported - - globals@11.12.0: - resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} - engines: {node: '>=4'} - - globalthis@1.0.4: - resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} - engines: {node: '>= 0.4'} - - gopd@1.0.1: - resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} - - graceful-fs@4.2.11: - resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - - has-flag@3.0.0: - resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} - engines: {node: '>=4'} - - has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - - has-property-descriptors@1.0.2: - resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} - - has-proto@1.0.3: - resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==} - engines: {node: '>= 0.4'} - - has-symbols@1.0.3: - resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} - engines: {node: '>= 0.4'} - - hash.js@1.1.7: - resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} - - hasown@2.0.2: - resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} - engines: {node: '>= 0.4'} - - hmac-drbg@1.0.1: - resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} - - html-escaper@2.0.2: - resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} - - human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - - human-signals@5.0.0: - resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} - engines: {node: '>=16.17.0'} - - import-local@3.1.0: - resolution: {integrity: sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==} - engines: {node: '>=8'} - hasBin: true - - imurmurhash@0.1.4: - resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} - engines: {node: '>=0.8.19'} - - inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. - - inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - - is-arrayish@0.2.1: - resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - - is-core-module@2.14.0: - resolution: {integrity: sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==} - engines: {node: '>= 0.4'} - - is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - - is-generator-fn@2.1.0: - resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==} - engines: {node: '>=6'} - - is-number@7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - - is-stream@2.0.1: - resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} - engines: {node: '>=8'} - - is-stream@3.0.0: - resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - - isexe@2.0.0: - resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - - isomorphic-ws@4.0.1: - resolution: {integrity: sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==} - peerDependencies: - ws: '*' - - istanbul-lib-coverage@3.2.2: - resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} - engines: {node: '>=8'} - - istanbul-lib-instrument@5.2.1: - resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} - engines: {node: '>=8'} - - istanbul-lib-instrument@6.0.3: - resolution: {integrity: sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==} - engines: {node: '>=10'} - - istanbul-lib-report@3.0.1: - resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==} - engines: {node: '>=10'} - - istanbul-lib-source-maps@4.0.1: - resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} - engines: {node: '>=10'} - - istanbul-reports@3.1.7: - resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} - engines: {node: '>=8'} - - jest-changed-files@29.7.0: - resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-circus@29.7.0: - resolution: {integrity: sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-cli@29.7.0: - resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - hasBin: true - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - - jest-config@29.7.0: - resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@types/node': '*' - ts-node: '>=9.0.0' - peerDependenciesMeta: - '@types/node': - optional: true - ts-node: - optional: true - - jest-diff@29.7.0: - resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-docblock@29.7.0: - resolution: {integrity: sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-each@29.7.0: - resolution: {integrity: sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-environment-node@29.7.0: - resolution: {integrity: sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-get-type@29.6.3: - resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-haste-map@29.7.0: - resolution: {integrity: sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-leak-detector@29.7.0: - resolution: {integrity: sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-matcher-utils@29.7.0: - resolution: {integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-message-util@29.7.0: - resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-mock@29.7.0: - resolution: {integrity: sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-pnp-resolver@1.2.3: - resolution: {integrity: sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==} - engines: {node: '>=6'} - peerDependencies: - jest-resolve: '*' - peerDependenciesMeta: - jest-resolve: - optional: true - - jest-regex-util@29.6.3: - resolution: {integrity: sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-resolve-dependencies@29.7.0: - resolution: {integrity: sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-resolve@29.7.0: - resolution: {integrity: sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-runner@29.7.0: - resolution: {integrity: sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-runtime@29.7.0: - resolution: {integrity: sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-snapshot@29.7.0: - resolution: {integrity: sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-util@29.7.0: - resolution: {integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-validate@29.7.0: - resolution: {integrity: sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-watcher@29.7.0: - resolution: {integrity: sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest-worker@29.7.0: - resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - jest@29.7.0: - resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - hasBin: true - peerDependencies: - node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0 - peerDependenciesMeta: - node-notifier: - optional: true - - js-tokens@4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - - js-yaml@3.14.1: - resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} - hasBin: true - - jsesc@2.5.2: - resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} - engines: {node: '>=4'} - hasBin: true - - json-parse-even-better-errors@2.3.1: - resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - - json5@2.2.3: - resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} - engines: {node: '>=6'} - hasBin: true - - kleur@3.0.3: - resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} - engines: {node: '>=6'} - - leven@3.1.0: - resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} - engines: {node: '>=6'} - - libsodium-sumo@0.7.14: - resolution: {integrity: sha512-2nDge6qlAjcwyslAhWfVumlkeSNK5+WCfKa2/VEq9prvlT5vP2FR0m0o5hmKaYqfsZ4TQVj5czQsimZvXDB1CQ==} - - libsodium-wrappers-sumo@0.7.14: - resolution: {integrity: sha512-0lm7ZwN5a95J2yUi8R1rgQeeaVDIWnvNzgVmXmZswis4mC+bQtbDrB+QpJlL4qklaKx3hVpJjoc6ubzJFiv64Q==} - - lines-and-columns@1.2.4: - resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - - locate-path@5.0.0: - resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} - engines: {node: '>=8'} - - long@4.0.0: - resolution: {integrity: sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==} - - loupe@3.1.1: - resolution: {integrity: sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==} - - lru-cache@5.1.1: - resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} - - magic-string@0.30.10: - resolution: {integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==} - - make-dir@4.0.0: - resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} - engines: {node: '>=10'} - - make-error@1.3.6: - resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - - makeerror@1.0.12: - resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} - - merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - - micromatch@4.0.7: - resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} - engines: {node: '>=8.6'} - - mime-db@1.52.0: - resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} - engines: {node: '>= 0.6'} - - mime-types@2.1.35: - resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} - engines: {node: '>= 0.6'} - - mimic-fn@2.1.0: - resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} - engines: {node: '>=6'} - - mimic-fn@4.0.0: - resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} - engines: {node: '>=12'} - - minimalistic-assert@1.0.1: - resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} - - minimalistic-crypto-utils@1.0.1: - resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} - - minimatch@3.1.2: - resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} - - ms@2.1.2: - resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - - nanoid@3.3.7: - resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - - natural-compare@1.4.0: - resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - - node-int64@0.4.0: - resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} - - node-releases@2.0.17: - resolution: {integrity: sha512-Ww6ZlOiEQfPfXM45v17oabk77Z7mg5bOt7AjDyzy7RjK9OrLrLC8dyZQoAPEOtFX9SaNf1Tdvr5gRJWdTJj7GA==} - - normalize-path@3.0.0: - resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} - engines: {node: '>=0.10.0'} - - npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - - npm-run-path@5.3.0: - resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - - object-keys@1.1.1: - resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} - engines: {node: '>= 0.4'} - - once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - - onetime@5.1.2: - resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} - engines: {node: '>=6'} - - onetime@6.0.0: - resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} - engines: {node: '>=12'} - - p-limit@2.3.0: - resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} - engines: {node: '>=6'} - - p-limit@3.1.0: - resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} - engines: {node: '>=10'} - - p-locate@4.1.0: - resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} - engines: {node: '>=8'} - - p-try@2.2.0: - resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} - engines: {node: '>=6'} - - parse-json@5.2.0: - resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} - engines: {node: '>=8'} - - path-exists@4.0.0: - resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} - engines: {node: '>=8'} - - path-is-absolute@1.0.1: - resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} - engines: {node: '>=0.10.0'} - - path-key@3.1.1: - resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} - engines: {node: '>=8'} - - path-key@4.0.0: - resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} - engines: {node: '>=12'} - - path-parse@1.0.7: - resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - - pathe@1.1.2: - resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} - - pathval@2.0.0: - resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} - engines: {node: '>= 14.16'} - - picocolors@1.0.1: - resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} - - picomatch@2.3.1: - resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} - engines: {node: '>=8.6'} - - pirates@4.0.6: - resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} - engines: {node: '>= 6'} - - pkg-dir@4.2.0: - resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} - engines: {node: '>=8'} - - postcss@8.4.39: - resolution: {integrity: sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw==} - engines: {node: ^10 || ^12 || >=14} - - prettier@3.3.3: - resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} - engines: {node: '>=14'} - hasBin: true - - pretty-format@29.7.0: - resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - - prompts@2.4.2: - resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} - engines: {node: '>= 6'} - - protobufjs@6.11.4: - resolution: {integrity: sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==} - hasBin: true - - proxy-from-env@1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - - pure-rand@6.1.0: - resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} - - react-is@18.3.1: - resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} - - readonly-date@1.0.0: - resolution: {integrity: sha512-tMKIV7hlk0h4mO3JTmmVuIlJVXjKk3Sep9Bf5OH0O+758ruuVkUy2J9SttDLm91IEX/WHlXPSpxMGjPj4beMIQ==} - - require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - - resolve-cwd@3.0.0: - resolution: {integrity: sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==} - engines: {node: '>=8'} - - resolve-from@5.0.0: - resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} - engines: {node: '>=8'} - - resolve.exports@2.0.2: - resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==} - engines: {node: '>=10'} - - resolve@1.22.8: - resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} - hasBin: true - - rollup@4.18.1: - resolution: {integrity: sha512-Elx2UT8lzxxOXMpy5HWQGZqkrQOtrVDDa/bm9l10+U4rQnVzbL/LgZ4NOM1MPIDyHk69W4InuYDF5dzRh4Kw1A==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - - semver@6.3.1: - resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} - hasBin: true - - semver@7.6.3: - resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} - engines: {node: '>=10'} - hasBin: true - - shebang-command@2.0.0: - resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} - engines: {node: '>=8'} - - shebang-regex@3.0.0: - resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} - engines: {node: '>=8'} - - siginfo@2.0.0: - resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} - - signal-exit@3.0.7: - resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} - - signal-exit@4.1.0: - resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} - engines: {node: '>=14'} - - sisteransi@1.0.5: - resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} - - slash@3.0.0: - resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} - engines: {node: '>=8'} - - source-map-js@1.2.0: - resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} - engines: {node: '>=0.10.0'} - - source-map-support@0.5.13: - resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==} - - source-map-support@0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - - source-map@0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} - engines: {node: '>=0.10.0'} - - sprintf-js@1.0.3: - resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} - - stack-utils@2.0.6: - resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} - engines: {node: '>=10'} - - stackback@0.0.2: - resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} - - std-env@3.7.0: - resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} - - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: - resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35} - version: 0.11.4 - - string-length@4.0.2: - resolution: {integrity: sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==} - engines: {node: '>=10'} - - string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} - - strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} - - strip-bom@4.0.0: - resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} - engines: {node: '>=8'} - - strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - - strip-final-newline@3.0.0: - resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} - engines: {node: '>=12'} - - strip-json-comments@3.1.1: - resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} - engines: {node: '>=8'} - - supports-color@5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} - - supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - - supports-color@8.1.1: - resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} - engines: {node: '>=10'} - - supports-preserve-symlinks-flag@1.0.0: - resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} - engines: {node: '>= 0.4'} - - symbol-observable@2.0.3: - resolution: {integrity: sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA==} - engines: {node: '>=0.10'} - - terser@5.31.3: - resolution: {integrity: sha512-pAfYn3NIZLyZpa83ZKigvj6Rn9c/vd5KfYGX7cN1mnzqgDcxWvrU5ZtAfIKhEXz9nRecw4z3LXkjaq96/qZqAA==} - engines: {node: '>=10'} - hasBin: true - - test-exclude@6.0.0: - resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} - engines: {node: '>=8'} - - tinybench@2.8.0: - resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} - - tinypool@1.0.0: - resolution: {integrity: sha512-KIKExllK7jp3uvrNtvRBYBWBOAXSX8ZvoaD8T+7KB/QHIuoJW3Pmr60zucywjAlMb5TeXUkcs/MWeWLu0qvuAQ==} - engines: {node: ^18.0.0 || >=20.0.0} - - tinyrainbow@1.2.0: - resolution: {integrity: sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==} - engines: {node: '>=14.0.0'} - - tinyspy@3.0.0: - resolution: {integrity: sha512-q5nmENpTHgiPVd1cJDDc9cVoYN5x4vCvwT3FMilvKPKneCBZAxn2YWQjDF0UMcE9k0Cay1gBiDfTMU0g+mPMQA==} - engines: {node: '>=14.0.0'} - - tmpl@1.0.5: - resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} - - to-fast-properties@2.0.0: - resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} - engines: {node: '>=4'} - - to-regex-range@5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} - - ts-node@10.9.2: - resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} - hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - - type-detect@4.0.8: - resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} - engines: {node: '>=4'} - - type-fest@0.21.3: - resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} - engines: {node: '>=10'} - - typescript@5.5.3: - resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==} - engines: {node: '>=14.17'} - hasBin: true - - undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - - update-browserslist-db@1.1.0: - resolution: {integrity: sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==} - hasBin: true - peerDependencies: - browserslist: '>= 4.21.0' - - v8-compile-cache-lib@3.0.1: - resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - - v8-to-istanbul@9.3.0: - resolution: {integrity: sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==} - engines: {node: '>=10.12.0'} - - vite-node@2.0.3: - resolution: {integrity: sha512-14jzwMx7XTcMB+9BhGQyoEAmSl0eOr3nrnn+Z12WNERtOvLN+d2scbRUvyni05rT3997Bg+rZb47NyP4IQPKXg==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - - vite@5.3.4: - resolution: {integrity: sha512-Cw+7zL3ZG9/NZBB8C+8QbQZmR54GwqIz+WMI4b3JgdYJvX+ny9AjJXqkGQlDXSXRP9rP0B4tbciRMOVEKulVOA==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - - vitest@2.0.3: - resolution: {integrity: sha512-o3HRvU93q6qZK4rI2JrhKyZMMuxg/JRt30E6qeQs6ueaiz5hr1cPj+Sk2kATgQzMMqsa2DiNI0TIK++1ULx8Jw==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 2.0.3 - '@vitest/ui': 2.0.3 - happy-dom: '*' - jsdom: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@types/node': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - - walker@1.0.8: - resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} - - which@2.0.2: - resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} - engines: {node: '>= 8'} - hasBin: true - - why-is-node-running@2.3.0: - resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} - engines: {node: '>=8'} - hasBin: true - - wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} - - wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - - write-file-atomic@4.0.2: - resolution: {integrity: sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==} - engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} - - ws@7.5.10: - resolution: {integrity: sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==} - engines: {node: '>=8.3.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - - xstream@11.14.0: - resolution: {integrity: sha512-1bLb+kKKtKPbgTK6i/BaoAn03g47PpFstlbe1BA+y3pNS/LfvcaghS5BFf9+EE1J+KwSQsEpfJvFN5GqFtiNmw==} - - y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - - yallist@3.1.1: - resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} - - yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} - - yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} - - yn@3.1.1: - resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} - engines: {node: '>=6'} - - yocto-queue@0.1.0: - resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} - engines: {node: '>=10'} - -snapshots: - - '@ampproject/remapping@2.3.0': - dependencies: - '@jridgewell/gen-mapping': 0.3.5 - '@jridgewell/trace-mapping': 0.3.25 - - '@babel/code-frame@7.24.7': - dependencies: - '@babel/highlight': 7.24.7 - picocolors: 1.0.1 - - '@babel/compat-data@7.24.9': {} - - '@babel/core@7.24.9': - dependencies: - '@ampproject/remapping': 2.3.0 - '@babel/code-frame': 7.24.7 - '@babel/generator': 7.24.10 - '@babel/helper-compilation-targets': 7.24.8 - '@babel/helper-module-transforms': 7.24.9(@babel/core@7.24.9) - '@babel/helpers': 7.24.8 - '@babel/parser': 7.24.8 - '@babel/template': 7.24.7 - '@babel/traverse': 7.24.8 - '@babel/types': 7.24.9 - convert-source-map: 2.0.0 - debug: 4.3.5 - gensync: 1.0.0-beta.2 - json5: 2.2.3 - semver: 6.3.1 - transitivePeerDependencies: - - supports-color - - '@babel/generator@7.24.10': - dependencies: - '@babel/types': 7.24.9 - '@jridgewell/gen-mapping': 0.3.5 - '@jridgewell/trace-mapping': 0.3.25 - jsesc: 2.5.2 - - '@babel/helper-compilation-targets@7.24.8': - dependencies: - '@babel/compat-data': 7.24.9 - '@babel/helper-validator-option': 7.24.8 - browserslist: 4.23.2 - lru-cache: 5.1.1 - semver: 6.3.1 - - '@babel/helper-environment-visitor@7.24.7': - dependencies: - '@babel/types': 7.24.9 - - '@babel/helper-function-name@7.24.7': - dependencies: - '@babel/template': 7.24.7 - '@babel/types': 7.24.9 - - '@babel/helper-hoist-variables@7.24.7': - dependencies: - '@babel/types': 7.24.9 - - '@babel/helper-module-imports@7.24.7': - dependencies: - '@babel/traverse': 7.24.8 - '@babel/types': 7.24.9 - transitivePeerDependencies: - - supports-color - - '@babel/helper-module-transforms@7.24.9(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-environment-visitor': 7.24.7 - '@babel/helper-module-imports': 7.24.7 - '@babel/helper-simple-access': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 - '@babel/helper-validator-identifier': 7.24.7 - transitivePeerDependencies: - - supports-color - - '@babel/helper-plugin-utils@7.24.8': {} - - '@babel/helper-simple-access@7.24.7': - dependencies: - '@babel/traverse': 7.24.8 - '@babel/types': 7.24.9 - transitivePeerDependencies: - - supports-color - - '@babel/helper-split-export-declaration@7.24.7': - dependencies: - '@babel/types': 7.24.9 - - '@babel/helper-string-parser@7.24.8': {} - - '@babel/helper-validator-identifier@7.24.7': {} - - '@babel/helper-validator-option@7.24.8': {} - - '@babel/helpers@7.24.8': - dependencies: - '@babel/template': 7.24.7 - '@babel/types': 7.24.9 - - '@babel/highlight@7.24.7': - dependencies: - '@babel/helper-validator-identifier': 7.24.7 - chalk: 2.4.2 - js-tokens: 4.0.0 - picocolors: 1.0.1 - - '@babel/parser@7.24.8': - dependencies: - '@babel/types': 7.24.9 - - '@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-jsx@7.24.7(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-logical-assignment-operators@7.10.4(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/plugin-syntax-typescript@7.24.7(@babel/core@7.24.9)': - dependencies: - '@babel/core': 7.24.9 - '@babel/helper-plugin-utils': 7.24.8 - - '@babel/template@7.24.7': - dependencies: - '@babel/code-frame': 7.24.7 - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 - - '@babel/traverse@7.24.8': - dependencies: - '@babel/code-frame': 7.24.7 - '@babel/generator': 7.24.10 - '@babel/helper-environment-visitor': 7.24.7 - '@babel/helper-function-name': 7.24.7 - '@babel/helper-hoist-variables': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 - debug: 4.3.5 - globals: 11.12.0 - transitivePeerDependencies: - - supports-color - - '@babel/types@7.24.9': - dependencies: - '@babel/helper-string-parser': 7.24.8 - '@babel/helper-validator-identifier': 7.24.7 - to-fast-properties: 2.0.0 - - '@bcoe/v8-coverage@0.2.3': {} - - '@confio/ics23@0.6.8': - dependencies: - '@noble/hashes': 1.4.0 - protobufjs: 6.11.4 - - '@cosmjs/amino@0.32.4': - dependencies: - '@cosmjs/crypto': 0.32.4 - '@cosmjs/encoding': 0.32.4 - '@cosmjs/math': 0.32.4 - '@cosmjs/utils': 0.32.4 - - '@cosmjs/crypto@0.32.4': - dependencies: - '@cosmjs/encoding': 0.32.4 - '@cosmjs/math': 0.32.4 - '@cosmjs/utils': 0.32.4 - '@noble/hashes': 1.4.0 - bn.js: 5.2.1 - elliptic: 6.5.6 - libsodium-wrappers-sumo: 0.7.14 - - '@cosmjs/encoding@0.32.4': - dependencies: - base64-js: 1.5.1 - bech32: 1.1.4 - readonly-date: 1.0.0 - - '@cosmjs/json-rpc@0.32.4': - dependencies: - '@cosmjs/stream': 0.32.4 - xstream: 11.14.0 - - '@cosmjs/math@0.32.4': - dependencies: - bn.js: 5.2.1 - - '@cosmjs/proto-signing@0.32.4': - dependencies: - '@cosmjs/amino': 0.32.4 - '@cosmjs/crypto': 0.32.4 - '@cosmjs/encoding': 0.32.4 - '@cosmjs/math': 0.32.4 - '@cosmjs/utils': 0.32.4 - cosmjs-types: 0.9.0 - - '@cosmjs/socket@0.32.4': - dependencies: - '@cosmjs/stream': 0.32.4 - isomorphic-ws: 4.0.1(ws@7.5.10) - ws: 7.5.10 - xstream: 11.14.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - - '@cosmjs/stargate@0.32.4': - dependencies: - '@confio/ics23': 0.6.8 - '@cosmjs/amino': 0.32.4 - '@cosmjs/encoding': 0.32.4 - '@cosmjs/math': 0.32.4 - '@cosmjs/proto-signing': 0.32.4 - '@cosmjs/stream': 0.32.4 - '@cosmjs/tendermint-rpc': 0.32.4 - '@cosmjs/utils': 0.32.4 - cosmjs-types: 0.9.0 - xstream: 11.14.0 - transitivePeerDependencies: - - bufferutil - - debug - - utf-8-validate - - '@cosmjs/stream@0.32.4': - dependencies: - xstream: 11.14.0 - - '@cosmjs/tendermint-rpc@0.32.4': - dependencies: - '@cosmjs/crypto': 0.32.4 - '@cosmjs/encoding': 0.32.4 - '@cosmjs/json-rpc': 0.32.4 - '@cosmjs/math': 0.32.4 - '@cosmjs/socket': 0.32.4 - '@cosmjs/stream': 0.32.4 - '@cosmjs/utils': 0.32.4 - axios: 1.6.0 - readonly-date: 1.0.0 - xstream: 11.14.0 - transitivePeerDependencies: - - bufferutil - - debug - - utf-8-validate - - '@cosmjs/utils@0.32.4': {} - - '@cosmology/lcd@0.13.4': - dependencies: - axios: 1.6.0 - transitivePeerDependencies: - - debug - - '@cspotcode/source-map-support@0.8.1': - dependencies: - '@jridgewell/trace-mapping': 0.3.9 - optional: true - - '@esbuild/aix-ppc64@0.21.5': - optional: true - - '@esbuild/android-arm64@0.21.5': - optional: true - - '@esbuild/android-arm@0.21.5': - optional: true - - '@esbuild/android-x64@0.21.5': - optional: true - - '@esbuild/darwin-arm64@0.21.5': - optional: true - - '@esbuild/darwin-x64@0.21.5': - optional: true - - '@esbuild/freebsd-arm64@0.21.5': - optional: true - - '@esbuild/freebsd-x64@0.21.5': - optional: true - - '@esbuild/linux-arm64@0.21.5': - optional: true - - '@esbuild/linux-arm@0.21.5': - optional: true - - '@esbuild/linux-ia32@0.21.5': - optional: true - - '@esbuild/linux-loong64@0.21.5': - optional: true - - '@esbuild/linux-mips64el@0.21.5': - optional: true - - '@esbuild/linux-ppc64@0.21.5': - optional: true - - '@esbuild/linux-riscv64@0.21.5': - optional: true - - '@esbuild/linux-s390x@0.21.5': - optional: true - - '@esbuild/linux-x64@0.21.5': - optional: true - - '@esbuild/netbsd-x64@0.21.5': - optional: true - - '@esbuild/openbsd-x64@0.21.5': - optional: true - - '@esbuild/sunos-x64@0.21.5': - optional: true - - '@esbuild/win32-arm64@0.21.5': - optional: true - - '@esbuild/win32-ia32@0.21.5': - optional: true - - '@esbuild/win32-x64@0.21.5': - optional: true - - '@istanbuljs/load-nyc-config@1.1.0': - dependencies: - camelcase: 5.3.1 - find-up: 4.1.0 - get-package-type: 0.1.0 - js-yaml: 3.14.1 - resolve-from: 5.0.0 - - '@istanbuljs/schema@0.1.3': {} - - '@jest/console@29.7.0': - dependencies: - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - chalk: 4.1.2 - jest-message-util: 29.7.0 - jest-util: 29.7.0 - slash: 3.0.0 - - '@jest/core@29.7.0(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3))': - dependencies: - '@jest/console': 29.7.0 - '@jest/reporters': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - ansi-escapes: 4.3.2 - chalk: 4.1.2 - ci-info: 3.9.0 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - jest-haste-map: 29.7.0 - jest-message-util: 29.7.0 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-resolve-dependencies: 29.7.0 - jest-runner: 29.7.0 - jest-runtime: 29.7.0 - jest-snapshot: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - jest-watcher: 29.7.0 - micromatch: 4.0.7 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-ansi: 6.0.1 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - - ts-node - - '@jest/environment@29.7.0': - dependencies: - '@jest/fake-timers': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - jest-mock: 29.7.0 - - '@jest/expect-utils@29.7.0': - dependencies: - jest-get-type: 29.6.3 - - '@jest/expect@29.7.0': - dependencies: - expect: 29.7.0 - jest-snapshot: 29.7.0 - transitivePeerDependencies: - - supports-color - - '@jest/fake-timers@29.7.0': - dependencies: - '@jest/types': 29.6.3 - '@sinonjs/fake-timers': 10.3.0 - '@types/node': 20.14.11 - jest-message-util: 29.7.0 - jest-mock: 29.7.0 - jest-util: 29.7.0 - - '@jest/globals@29.7.0': - dependencies: - '@jest/environment': 29.7.0 - '@jest/expect': 29.7.0 - '@jest/types': 29.6.3 - jest-mock: 29.7.0 - transitivePeerDependencies: - - supports-color - - '@jest/reporters@29.7.0': - dependencies: - '@bcoe/v8-coverage': 0.2.3 - '@jest/console': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 20.14.11 - chalk: 4.1.2 - collect-v8-coverage: 1.0.2 - exit: 0.1.2 - glob: 7.2.3 - graceful-fs: 4.2.11 - istanbul-lib-coverage: 3.2.2 - istanbul-lib-instrument: 6.0.3 - istanbul-lib-report: 3.0.1 - istanbul-lib-source-maps: 4.0.1 - istanbul-reports: 3.1.7 - jest-message-util: 29.7.0 - jest-util: 29.7.0 - jest-worker: 29.7.0 - slash: 3.0.0 - string-length: 4.0.2 - strip-ansi: 6.0.1 - v8-to-istanbul: 9.3.0 - transitivePeerDependencies: - - supports-color - - '@jest/schemas@29.6.3': - dependencies: - '@sinclair/typebox': 0.27.8 - - '@jest/source-map@29.6.3': - dependencies: - '@jridgewell/trace-mapping': 0.3.25 - callsites: 3.1.0 - graceful-fs: 4.2.11 - - '@jest/test-result@29.7.0': - dependencies: - '@jest/console': 29.7.0 - '@jest/types': 29.6.3 - '@types/istanbul-lib-coverage': 2.0.6 - collect-v8-coverage: 1.0.2 - - '@jest/test-sequencer@29.7.0': - dependencies: - '@jest/test-result': 29.7.0 - graceful-fs: 4.2.11 - jest-haste-map: 29.7.0 - slash: 3.0.0 - - '@jest/transform@29.7.0': - dependencies: - '@babel/core': 7.24.9 - '@jest/types': 29.6.3 - '@jridgewell/trace-mapping': 0.3.25 - babel-plugin-istanbul: 6.1.1 - chalk: 4.1.2 - convert-source-map: 2.0.0 - fast-json-stable-stringify: 2.1.0 - graceful-fs: 4.2.11 - jest-haste-map: 29.7.0 - jest-regex-util: 29.6.3 - jest-util: 29.7.0 - micromatch: 4.0.7 - pirates: 4.0.6 - slash: 3.0.0 - write-file-atomic: 4.0.2 - transitivePeerDependencies: - - supports-color - - '@jest/types@29.6.3': - dependencies: - '@jest/schemas': 29.6.3 - '@types/istanbul-lib-coverage': 2.0.6 - '@types/istanbul-reports': 3.0.4 - '@types/node': 20.14.11 - '@types/yargs': 17.0.32 - chalk: 4.1.2 - - '@jridgewell/gen-mapping@0.3.5': - dependencies: - '@jridgewell/set-array': 1.2.1 - '@jridgewell/sourcemap-codec': 1.5.0 - '@jridgewell/trace-mapping': 0.3.25 - - '@jridgewell/resolve-uri@3.1.2': {} - - '@jridgewell/set-array@1.2.1': {} - - '@jridgewell/source-map@0.3.6': - dependencies: - '@jridgewell/gen-mapping': 0.3.5 - '@jridgewell/trace-mapping': 0.3.25 - optional: true - - '@jridgewell/sourcemap-codec@1.5.0': {} - - '@jridgewell/trace-mapping@0.3.25': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.0 - - '@jridgewell/trace-mapping@0.3.9': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.0 - optional: true - - '@noble/hashes@1.4.0': {} - - '@protobufjs/aspromise@1.1.2': {} - - '@protobufjs/base64@1.1.2': {} - - '@protobufjs/codegen@2.0.4': {} - - '@protobufjs/eventemitter@1.1.0': {} - - '@protobufjs/fetch@1.1.0': - dependencies: - '@protobufjs/aspromise': 1.1.2 - '@protobufjs/inquire': 1.1.0 - - '@protobufjs/float@1.0.2': {} - - '@protobufjs/inquire@1.1.0': {} - - '@protobufjs/path@1.1.2': {} - - '@protobufjs/pool@1.1.0': {} - - '@protobufjs/utf8@1.1.0': {} - - '@rollup/rollup-android-arm-eabi@4.18.1': - optional: true - - '@rollup/rollup-android-arm64@4.18.1': - optional: true - - '@rollup/rollup-darwin-arm64@4.18.1': - optional: true - - '@rollup/rollup-darwin-x64@4.18.1': - optional: true - - '@rollup/rollup-linux-arm-gnueabihf@4.18.1': - optional: true - - '@rollup/rollup-linux-arm-musleabihf@4.18.1': - optional: true - - '@rollup/rollup-linux-arm64-gnu@4.18.1': - optional: true - - '@rollup/rollup-linux-arm64-musl@4.18.1': - optional: true - - '@rollup/rollup-linux-powerpc64le-gnu@4.18.1': - optional: true - - '@rollup/rollup-linux-riscv64-gnu@4.18.1': - optional: true - - '@rollup/rollup-linux-s390x-gnu@4.18.1': - optional: true - - '@rollup/rollup-linux-x64-gnu@4.18.1': - optional: true - - '@rollup/rollup-linux-x64-musl@4.18.1': - optional: true - - '@rollup/rollup-win32-arm64-msvc@4.18.1': - optional: true - - '@rollup/rollup-win32-ia32-msvc@4.18.1': - optional: true - - '@rollup/rollup-win32-x64-msvc@4.18.1': - optional: true - - '@sinclair/typebox@0.27.8': {} - - '@sinonjs/commons@3.0.1': - dependencies: - type-detect: 4.0.8 - - '@sinonjs/fake-timers@10.3.0': - dependencies: - '@sinonjs/commons': 3.0.1 - - '@tsconfig/node10@1.0.11': - optional: true - - '@tsconfig/node12@1.0.11': - optional: true - - '@tsconfig/node14@1.0.3': - optional: true - - '@tsconfig/node16@1.0.4': - optional: true - - '@types/babel__core@7.20.5': - dependencies: - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 - '@types/babel__generator': 7.6.8 - '@types/babel__template': 7.4.4 - '@types/babel__traverse': 7.20.6 - - '@types/babel__generator@7.6.8': - dependencies: - '@babel/types': 7.24.9 - - '@types/babel__template@7.4.4': - dependencies: - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 - - '@types/babel__traverse@7.20.6': - dependencies: - '@babel/types': 7.24.9 - - '@types/estree@1.0.5': {} - - '@types/graceful-fs@4.1.9': - dependencies: - '@types/node': 20.14.11 - - '@types/istanbul-lib-coverage@2.0.6': {} - - '@types/istanbul-lib-report@3.0.3': - dependencies: - '@types/istanbul-lib-coverage': 2.0.6 - - '@types/istanbul-reports@3.0.4': - dependencies: - '@types/istanbul-lib-report': 3.0.3 - - '@types/long@4.0.2': {} - - '@types/node@20.14.11': - dependencies: - undici-types: 5.26.5 - - '@types/stack-utils@2.0.3': {} - - '@types/yargs-parser@21.0.3': {} - - '@types/yargs@17.0.32': - dependencies: - '@types/yargs-parser': 21.0.3 - - '@vitest/expect@2.0.3': - dependencies: - '@vitest/spy': 2.0.3 - '@vitest/utils': 2.0.3 - chai: 5.1.1 - tinyrainbow: 1.2.0 - - '@vitest/pretty-format@2.0.3': - dependencies: - tinyrainbow: 1.2.0 - - '@vitest/runner@2.0.3': - dependencies: - '@vitest/utils': 2.0.3 - pathe: 1.1.2 - - '@vitest/snapshot@2.0.3': - dependencies: - '@vitest/pretty-format': 2.0.3 - magic-string: 0.30.10 - pathe: 1.1.2 - - '@vitest/spy@2.0.3': - dependencies: - tinyspy: 3.0.0 - - '@vitest/utils@2.0.3': - dependencies: - '@vitest/pretty-format': 2.0.3 - estree-walker: 3.0.3 - loupe: 3.1.1 - tinyrainbow: 1.2.0 - - acorn-walk@8.3.3: - dependencies: - acorn: 8.12.1 - optional: true - - acorn@8.12.1: - optional: true - - ansi-escapes@4.3.2: - dependencies: - type-fest: 0.21.3 - - ansi-regex@5.0.1: {} - - ansi-styles@3.2.1: - dependencies: - color-convert: 1.9.3 - - ansi-styles@4.3.0: - dependencies: - color-convert: 2.0.1 - - ansi-styles@5.2.0: {} - - anymatch@3.1.3: - dependencies: - normalize-path: 3.0.0 - picomatch: 2.3.1 - - arg@4.1.3: - optional: true - - argparse@1.0.10: - dependencies: - sprintf-js: 1.0.3 - - assertion-error@2.0.1: {} - - asynckit@0.4.0: {} - - axios@1.6.0: - dependencies: - follow-redirects: 1.15.6 - form-data: 4.0.0 - proxy-from-env: 1.1.0 - transitivePeerDependencies: - - debug - - babel-jest@29.7.0(@babel/core@7.24.9): - dependencies: - '@babel/core': 7.24.9 - '@jest/transform': 29.7.0 - '@types/babel__core': 7.20.5 - babel-plugin-istanbul: 6.1.1 - babel-preset-jest: 29.6.3(@babel/core@7.24.9) - chalk: 4.1.2 - graceful-fs: 4.2.11 - slash: 3.0.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-istanbul@6.1.1: - dependencies: - '@babel/helper-plugin-utils': 7.24.8 - '@istanbuljs/load-nyc-config': 1.1.0 - '@istanbuljs/schema': 0.1.3 - istanbul-lib-instrument: 5.2.1 - test-exclude: 6.0.0 - transitivePeerDependencies: - - supports-color - - babel-plugin-jest-hoist@29.6.3: - dependencies: - '@babel/template': 7.24.7 - '@babel/types': 7.24.9 - '@types/babel__core': 7.20.5 - '@types/babel__traverse': 7.20.6 - - babel-preset-current-node-syntax@1.0.1(@babel/core@7.24.9): - dependencies: - '@babel/core': 7.24.9 - '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.24.9) - '@babel/plugin-syntax-bigint': 7.8.3(@babel/core@7.24.9) - '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.24.9) - '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.24.9) - '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.24.9) - '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.24.9) - '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.24.9) - '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.24.9) - '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.24.9) - '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.24.9) - '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.24.9) - '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.24.9) - - babel-preset-jest@29.6.3(@babel/core@7.24.9): - dependencies: - '@babel/core': 7.24.9 - babel-plugin-jest-hoist: 29.6.3 - babel-preset-current-node-syntax: 1.0.1(@babel/core@7.24.9) - - balanced-match@1.0.2: {} - - base64-js@1.5.1: {} - - bech32@1.1.4: {} - - bech32@2.0.0: {} - - bn.js@4.12.0: {} - - bn.js@5.2.1: {} - - brace-expansion@1.1.11: - dependencies: - balanced-match: 1.0.2 - concat-map: 0.0.1 - - braces@3.0.3: - dependencies: - fill-range: 7.1.1 - - brorand@1.1.0: {} - - browserslist@4.23.2: - dependencies: - caniuse-lite: 1.0.30001642 - electron-to-chromium: 1.4.829 - node-releases: 2.0.17 - update-browserslist-db: 1.1.0(browserslist@4.23.2) - - bser@2.1.1: - dependencies: - node-int64: 0.4.0 - - buffer-from@1.1.2: {} - - cac@6.7.14: {} - - callsites@3.1.0: {} - - camelcase@5.3.1: {} - - camelcase@6.3.0: {} - - caniuse-lite@1.0.30001642: {} - - chai@5.1.1: - dependencies: - assertion-error: 2.0.1 - check-error: 2.1.1 - deep-eql: 5.0.2 - loupe: 3.1.1 - pathval: 2.0.0 - - chalk@2.4.2: - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - - chalk@4.1.2: - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - - char-regex@1.0.2: {} - - check-error@2.1.1: {} - - ci-info@3.9.0: {} - - cjs-module-lexer@1.3.1: {} - - cliui@8.0.1: - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - - co@4.6.0: {} - - collect-v8-coverage@1.0.2: {} - - color-convert@1.9.3: - dependencies: - color-name: 1.1.3 - - color-convert@2.0.1: - dependencies: - color-name: 1.1.4 - - color-name@1.1.3: {} - - color-name@1.1.4: {} - - combined-stream@1.0.8: - dependencies: - delayed-stream: 1.0.0 - - commander@2.20.3: - optional: true - - concat-map@0.0.1: {} - - convert-source-map@2.0.0: {} - - cosmjs-types@0.9.0: {} - - create-jest@29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)): - dependencies: - '@jest/types': 29.6.3 - chalk: 4.1.2 - exit: 0.1.2 - graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - jest-util: 29.7.0 - prompts: 2.4.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - - create-require@1.1.1: - optional: true - - cross-spawn@7.0.3: - dependencies: - path-key: 3.1.1 - shebang-command: 2.0.0 - which: 2.0.2 - - debug@4.3.5: - dependencies: - ms: 2.1.2 - - dedent@1.5.3: {} - - deep-eql@5.0.2: {} - - deepmerge@4.3.1: {} - - define-data-property@1.1.4: - dependencies: - es-define-property: 1.0.0 - es-errors: 1.3.0 - gopd: 1.0.1 - - define-properties@1.2.1: - dependencies: - define-data-property: 1.1.4 - has-property-descriptors: 1.0.2 - object-keys: 1.1.1 - - delayed-stream@1.0.0: {} - - detect-newline@3.1.0: {} - - diff-sequences@29.6.3: {} - - diff@4.0.2: - optional: true - - electron-to-chromium@1.4.829: {} - - elliptic@6.5.6: - dependencies: - bn.js: 4.12.0 - brorand: 1.1.0 - hash.js: 1.1.7 - hmac-drbg: 1.0.1 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - - emittery@0.13.1: {} - - emoji-regex@8.0.0: {} - - error-ex@1.3.2: - dependencies: - is-arrayish: 0.2.1 - - es-define-property@1.0.0: - dependencies: - get-intrinsic: 1.2.4 - - es-errors@1.3.0: {} - - esbuild@0.21.5: - optionalDependencies: - '@esbuild/aix-ppc64': 0.21.5 - '@esbuild/android-arm': 0.21.5 - '@esbuild/android-arm64': 0.21.5 - '@esbuild/android-x64': 0.21.5 - '@esbuild/darwin-arm64': 0.21.5 - '@esbuild/darwin-x64': 0.21.5 - '@esbuild/freebsd-arm64': 0.21.5 - '@esbuild/freebsd-x64': 0.21.5 - '@esbuild/linux-arm': 0.21.5 - '@esbuild/linux-arm64': 0.21.5 - '@esbuild/linux-ia32': 0.21.5 - '@esbuild/linux-loong64': 0.21.5 - '@esbuild/linux-mips64el': 0.21.5 - '@esbuild/linux-ppc64': 0.21.5 - '@esbuild/linux-riscv64': 0.21.5 - '@esbuild/linux-s390x': 0.21.5 - '@esbuild/linux-x64': 0.21.5 - '@esbuild/netbsd-x64': 0.21.5 - '@esbuild/openbsd-x64': 0.21.5 - '@esbuild/sunos-x64': 0.21.5 - '@esbuild/win32-arm64': 0.21.5 - '@esbuild/win32-ia32': 0.21.5 - '@esbuild/win32-x64': 0.21.5 - - escalade@3.1.2: {} - - escape-string-regexp@1.0.5: {} - - escape-string-regexp@2.0.0: {} - - esprima@4.0.1: {} - - estree-walker@3.0.3: - dependencies: - '@types/estree': 1.0.5 - - execa@5.1.1: - dependencies: - cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - - execa@8.0.1: - dependencies: - cross-spawn: 7.0.3 - get-stream: 8.0.1 - human-signals: 5.0.0 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.3.0 - onetime: 6.0.0 - signal-exit: 4.1.0 - strip-final-newline: 3.0.0 - - exit@0.1.2: {} - - expect@29.7.0: - dependencies: - '@jest/expect-utils': 29.7.0 - jest-get-type: 29.6.3 - jest-matcher-utils: 29.7.0 - jest-message-util: 29.7.0 - jest-util: 29.7.0 - - fast-json-stable-stringify@2.1.0: {} - - fb-watchman@2.0.2: - dependencies: - bser: 2.1.1 - - fill-range@7.1.1: - dependencies: - to-regex-range: 5.0.1 - - find-up@4.1.0: - dependencies: - locate-path: 5.0.0 - path-exists: 4.0.0 - - follow-redirects@1.15.6: {} - - form-data@4.0.0: - dependencies: - asynckit: 0.4.0 - combined-stream: 1.0.8 - mime-types: 2.1.35 - - fs.realpath@1.0.0: {} - - fsevents@2.3.3: - optional: true - - function-bind@1.1.2: {} - - gensync@1.0.0-beta.2: {} - - get-caller-file@2.0.5: {} - - get-func-name@2.0.2: {} - - get-intrinsic@1.2.4: - dependencies: - es-errors: 1.3.0 - function-bind: 1.1.2 - has-proto: 1.0.3 - has-symbols: 1.0.3 - hasown: 2.0.2 - - get-package-type@0.1.0: {} - - get-stream@6.0.1: {} - - get-stream@8.0.1: {} - - glob@7.2.3: - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - - globals@11.12.0: {} - - globalthis@1.0.4: - dependencies: - define-properties: 1.2.1 - gopd: 1.0.1 - - gopd@1.0.1: - dependencies: - get-intrinsic: 1.2.4 - - graceful-fs@4.2.11: {} - - has-flag@3.0.0: {} - - has-flag@4.0.0: {} - - has-property-descriptors@1.0.2: - dependencies: - es-define-property: 1.0.0 - - has-proto@1.0.3: {} - - has-symbols@1.0.3: {} - - hash.js@1.1.7: - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - - hasown@2.0.2: - dependencies: - function-bind: 1.1.2 - - hmac-drbg@1.0.1: - dependencies: - hash.js: 1.1.7 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - - html-escaper@2.0.2: {} - - human-signals@2.1.0: {} - - human-signals@5.0.0: {} - - import-local@3.1.0: - dependencies: - pkg-dir: 4.2.0 - resolve-cwd: 3.0.0 - - imurmurhash@0.1.4: {} - - inflight@1.0.6: - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - - inherits@2.0.4: {} - - is-arrayish@0.2.1: {} - - is-core-module@2.14.0: - dependencies: - hasown: 2.0.2 - - is-fullwidth-code-point@3.0.0: {} - - is-generator-fn@2.1.0: {} - - is-number@7.0.0: {} - - is-stream@2.0.1: {} - - is-stream@3.0.0: {} - - isexe@2.0.0: {} - - isomorphic-ws@4.0.1(ws@7.5.10): - dependencies: - ws: 7.5.10 - - istanbul-lib-coverage@3.2.2: {} - - istanbul-lib-instrument@5.2.1: - dependencies: - '@babel/core': 7.24.9 - '@babel/parser': 7.24.8 - '@istanbuljs/schema': 0.1.3 - istanbul-lib-coverage: 3.2.2 - semver: 6.3.1 - transitivePeerDependencies: - - supports-color - - istanbul-lib-instrument@6.0.3: - dependencies: - '@babel/core': 7.24.9 - '@babel/parser': 7.24.8 - '@istanbuljs/schema': 0.1.3 - istanbul-lib-coverage: 3.2.2 - semver: 7.6.3 - transitivePeerDependencies: - - supports-color - - istanbul-lib-report@3.0.1: - dependencies: - istanbul-lib-coverage: 3.2.2 - make-dir: 4.0.0 - supports-color: 7.2.0 - - istanbul-lib-source-maps@4.0.1: - dependencies: - debug: 4.3.5 - istanbul-lib-coverage: 3.2.2 - source-map: 0.6.1 - transitivePeerDependencies: - - supports-color - - istanbul-reports@3.1.7: - dependencies: - html-escaper: 2.0.2 - istanbul-lib-report: 3.0.1 - - jest-changed-files@29.7.0: - dependencies: - execa: 5.1.1 - jest-util: 29.7.0 - p-limit: 3.1.0 - - jest-circus@29.7.0: - dependencies: - '@jest/environment': 29.7.0 - '@jest/expect': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - chalk: 4.1.2 - co: 4.6.0 - dedent: 1.5.3 - is-generator-fn: 2.1.0 - jest-each: 29.7.0 - jest-matcher-utils: 29.7.0 - jest-message-util: 29.7.0 - jest-runtime: 29.7.0 - jest-snapshot: 29.7.0 - jest-util: 29.7.0 - p-limit: 3.1.0 - pretty-format: 29.7.0 - pure-rand: 6.1.0 - slash: 3.0.0 - stack-utils: 2.0.6 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - - jest-cli@29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - '@jest/test-result': 29.7.0 - '@jest/types': 29.6.3 - chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - exit: 0.1.2 - import-local: 3.1.0 - jest-config: 29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - jest-util: 29.7.0 - jest-validate: 29.7.0 - yargs: 17.7.2 - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - - jest-config@29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)): - dependencies: - '@babel/core': 7.24.9 - '@jest/test-sequencer': 29.7.0 - '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@7.24.9) - chalk: 4.1.2 - ci-info: 3.9.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.7.0 - jest-environment-node: 29.7.0 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-runner: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - micromatch: 4.0.7 - parse-json: 5.2.0 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - optionalDependencies: - '@types/node': 20.14.11 - ts-node: 10.9.2(@types/node@20.14.11)(typescript@5.5.3) - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - - jest-diff@29.7.0: - dependencies: - chalk: 4.1.2 - diff-sequences: 29.6.3 - jest-get-type: 29.6.3 - pretty-format: 29.7.0 - - jest-docblock@29.7.0: - dependencies: - detect-newline: 3.1.0 - - jest-each@29.7.0: - dependencies: - '@jest/types': 29.6.3 - chalk: 4.1.2 - jest-get-type: 29.6.3 - jest-util: 29.7.0 - pretty-format: 29.7.0 - - jest-environment-node@29.7.0: - dependencies: - '@jest/environment': 29.7.0 - '@jest/fake-timers': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - jest-mock: 29.7.0 - jest-util: 29.7.0 - - jest-get-type@29.6.3: {} - - jest-haste-map@29.7.0: - dependencies: - '@jest/types': 29.6.3 - '@types/graceful-fs': 4.1.9 - '@types/node': 20.14.11 - anymatch: 3.1.3 - fb-watchman: 2.0.2 - graceful-fs: 4.2.11 - jest-regex-util: 29.6.3 - jest-util: 29.7.0 - jest-worker: 29.7.0 - micromatch: 4.0.7 - walker: 1.0.8 - optionalDependencies: - fsevents: 2.3.3 - - jest-leak-detector@29.7.0: - dependencies: - jest-get-type: 29.6.3 - pretty-format: 29.7.0 - - jest-matcher-utils@29.7.0: - dependencies: - chalk: 4.1.2 - jest-diff: 29.7.0 - jest-get-type: 29.6.3 - pretty-format: 29.7.0 - - jest-message-util@29.7.0: - dependencies: - '@babel/code-frame': 7.24.7 - '@jest/types': 29.6.3 - '@types/stack-utils': 2.0.3 - chalk: 4.1.2 - graceful-fs: 4.2.11 - micromatch: 4.0.7 - pretty-format: 29.7.0 - slash: 3.0.0 - stack-utils: 2.0.6 - - jest-mock@29.7.0: - dependencies: - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - jest-util: 29.7.0 - - jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): - optionalDependencies: - jest-resolve: 29.7.0 - - jest-regex-util@29.6.3: {} - - jest-resolve-dependencies@29.7.0: - dependencies: - jest-regex-util: 29.6.3 - jest-snapshot: 29.7.0 - transitivePeerDependencies: - - supports-color - - jest-resolve@29.7.0: - dependencies: - chalk: 4.1.2 - graceful-fs: 4.2.11 - jest-haste-map: 29.7.0 - jest-pnp-resolver: 1.2.3(jest-resolve@29.7.0) - jest-util: 29.7.0 - jest-validate: 29.7.0 - resolve: 1.22.8 - resolve.exports: 2.0.2 - slash: 3.0.0 - - jest-runner@29.7.0: - dependencies: - '@jest/console': 29.7.0 - '@jest/environment': 29.7.0 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - chalk: 4.1.2 - emittery: 0.13.1 - graceful-fs: 4.2.11 - jest-docblock: 29.7.0 - jest-environment-node: 29.7.0 - jest-haste-map: 29.7.0 - jest-leak-detector: 29.7.0 - jest-message-util: 29.7.0 - jest-resolve: 29.7.0 - jest-runtime: 29.7.0 - jest-util: 29.7.0 - jest-watcher: 29.7.0 - jest-worker: 29.7.0 - p-limit: 3.1.0 - source-map-support: 0.5.13 - transitivePeerDependencies: - - supports-color - - jest-runtime@29.7.0: - dependencies: - '@jest/environment': 29.7.0 - '@jest/fake-timers': 29.7.0 - '@jest/globals': 29.7.0 - '@jest/source-map': 29.6.3 - '@jest/test-result': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - chalk: 4.1.2 - cjs-module-lexer: 1.3.1 - collect-v8-coverage: 1.0.2 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-haste-map: 29.7.0 - jest-message-util: 29.7.0 - jest-mock: 29.7.0 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-snapshot: 29.7.0 - jest-util: 29.7.0 - slash: 3.0.0 - strip-bom: 4.0.0 - transitivePeerDependencies: - - supports-color - - jest-snapshot@29.7.0: - dependencies: - '@babel/core': 7.24.9 - '@babel/generator': 7.24.10 - '@babel/plugin-syntax-jsx': 7.24.7(@babel/core@7.24.9) - '@babel/plugin-syntax-typescript': 7.24.7(@babel/core@7.24.9) - '@babel/types': 7.24.9 - '@jest/expect-utils': 29.7.0 - '@jest/transform': 29.7.0 - '@jest/types': 29.6.3 - babel-preset-current-node-syntax: 1.0.1(@babel/core@7.24.9) - chalk: 4.1.2 - expect: 29.7.0 - graceful-fs: 4.2.11 - jest-diff: 29.7.0 - jest-get-type: 29.6.3 - jest-matcher-utils: 29.7.0 - jest-message-util: 29.7.0 - jest-util: 29.7.0 - natural-compare: 1.4.0 - pretty-format: 29.7.0 - semver: 7.6.3 - transitivePeerDependencies: - - supports-color - - jest-util@29.7.0: - dependencies: - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - chalk: 4.1.2 - ci-info: 3.9.0 - graceful-fs: 4.2.11 - picomatch: 2.3.1 - - jest-validate@29.7.0: - dependencies: - '@jest/types': 29.6.3 - camelcase: 6.3.0 - chalk: 4.1.2 - jest-get-type: 29.6.3 - leven: 3.1.0 - pretty-format: 29.7.0 - - jest-watcher@29.7.0: - dependencies: - '@jest/test-result': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 20.14.11 - ansi-escapes: 4.3.2 - chalk: 4.1.2 - emittery: 0.13.1 - jest-util: 29.7.0 - string-length: 4.0.2 - - jest-worker@29.7.0: - dependencies: - '@types/node': 20.14.11 - jest-util: 29.7.0 - merge-stream: 2.0.0 - supports-color: 8.1.1 - - jest@29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)): - dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - '@jest/types': 29.6.3 - import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@20.14.11)(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - supports-color - - ts-node - - js-tokens@4.0.0: {} - - js-yaml@3.14.1: - dependencies: - argparse: 1.0.10 - esprima: 4.0.1 - - jsesc@2.5.2: {} - - json-parse-even-better-errors@2.3.1: {} - - json5@2.2.3: {} - - kleur@3.0.3: {} - - leven@3.1.0: {} - - libsodium-sumo@0.7.14: {} - - libsodium-wrappers-sumo@0.7.14: - dependencies: - libsodium-sumo: 0.7.14 - - lines-and-columns@1.2.4: {} - - locate-path@5.0.0: - dependencies: - p-locate: 4.1.0 - - long@4.0.0: {} - - loupe@3.1.1: - dependencies: - get-func-name: 2.0.2 - - lru-cache@5.1.1: - dependencies: - yallist: 3.1.1 - - magic-string@0.30.10: - dependencies: - '@jridgewell/sourcemap-codec': 1.5.0 - - make-dir@4.0.0: - dependencies: - semver: 7.6.3 - - make-error@1.3.6: - optional: true - - makeerror@1.0.12: - dependencies: - tmpl: 1.0.5 - - merge-stream@2.0.0: {} - - micromatch@4.0.7: - dependencies: - braces: 3.0.3 - picomatch: 2.3.1 - - mime-db@1.52.0: {} - - mime-types@2.1.35: - dependencies: - mime-db: 1.52.0 - - mimic-fn@2.1.0: {} - - mimic-fn@4.0.0: {} - - minimalistic-assert@1.0.1: {} - - minimalistic-crypto-utils@1.0.1: {} - - minimatch@3.1.2: - dependencies: - brace-expansion: 1.1.11 - - ms@2.1.2: {} - - nanoid@3.3.7: {} - - natural-compare@1.4.0: {} - - node-int64@0.4.0: {} - - node-releases@2.0.17: {} - - normalize-path@3.0.0: {} - - npm-run-path@4.0.1: - dependencies: - path-key: 3.1.1 - - npm-run-path@5.3.0: - dependencies: - path-key: 4.0.0 - - object-keys@1.1.1: {} - - once@1.4.0: - dependencies: - wrappy: 1.0.2 - - onetime@5.1.2: - dependencies: - mimic-fn: 2.1.0 - - onetime@6.0.0: - dependencies: - mimic-fn: 4.0.0 - - p-limit@2.3.0: - dependencies: - p-try: 2.2.0 - - p-limit@3.1.0: - dependencies: - yocto-queue: 0.1.0 - - p-locate@4.1.0: - dependencies: - p-limit: 2.3.0 - - p-try@2.2.0: {} - - parse-json@5.2.0: - dependencies: - '@babel/code-frame': 7.24.7 - error-ex: 1.3.2 - json-parse-even-better-errors: 2.3.1 - lines-and-columns: 1.2.4 - - path-exists@4.0.0: {} - - path-is-absolute@1.0.1: {} - - path-key@3.1.1: {} - - path-key@4.0.0: {} - - path-parse@1.0.7: {} - - pathe@1.1.2: {} - - pathval@2.0.0: {} - - picocolors@1.0.1: {} - - picomatch@2.3.1: {} - - pirates@4.0.6: {} - - pkg-dir@4.2.0: - dependencies: - find-up: 4.1.0 - - postcss@8.4.39: - dependencies: - nanoid: 3.3.7 - picocolors: 1.0.1 - source-map-js: 1.2.0 - - prettier@3.3.3: {} - - pretty-format@29.7.0: - dependencies: - '@jest/schemas': 29.6.3 - ansi-styles: 5.2.0 - react-is: 18.3.1 - - prompts@2.4.2: - dependencies: - kleur: 3.0.3 - sisteransi: 1.0.5 - - protobufjs@6.11.4: - dependencies: - '@protobufjs/aspromise': 1.1.2 - '@protobufjs/base64': 1.1.2 - '@protobufjs/codegen': 2.0.4 - '@protobufjs/eventemitter': 1.1.0 - '@protobufjs/fetch': 1.1.0 - '@protobufjs/float': 1.0.2 - '@protobufjs/inquire': 1.1.0 - '@protobufjs/path': 1.1.2 - '@protobufjs/pool': 1.1.0 - '@protobufjs/utf8': 1.1.0 - '@types/long': 4.0.2 - '@types/node': 20.14.11 - long: 4.0.0 - - proxy-from-env@1.1.0: {} - - pure-rand@6.1.0: {} - - react-is@18.3.1: {} - - readonly-date@1.0.0: {} - - require-directory@2.1.1: {} - - resolve-cwd@3.0.0: - dependencies: - resolve-from: 5.0.0 - - resolve-from@5.0.0: {} - - resolve.exports@2.0.2: {} - - resolve@1.22.8: - dependencies: - is-core-module: 2.14.0 - path-parse: 1.0.7 - supports-preserve-symlinks-flag: 1.0.0 - - rollup@4.18.1: - dependencies: - '@types/estree': 1.0.5 - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.18.1 - '@rollup/rollup-android-arm64': 4.18.1 - '@rollup/rollup-darwin-arm64': 4.18.1 - '@rollup/rollup-darwin-x64': 4.18.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.18.1 - '@rollup/rollup-linux-arm-musleabihf': 4.18.1 - '@rollup/rollup-linux-arm64-gnu': 4.18.1 - '@rollup/rollup-linux-arm64-musl': 4.18.1 - '@rollup/rollup-linux-powerpc64le-gnu': 4.18.1 - '@rollup/rollup-linux-riscv64-gnu': 4.18.1 - '@rollup/rollup-linux-s390x-gnu': 4.18.1 - '@rollup/rollup-linux-x64-gnu': 4.18.1 - '@rollup/rollup-linux-x64-musl': 4.18.1 - '@rollup/rollup-win32-arm64-msvc': 4.18.1 - '@rollup/rollup-win32-ia32-msvc': 4.18.1 - '@rollup/rollup-win32-x64-msvc': 4.18.1 - fsevents: 2.3.3 - - semver@6.3.1: {} - - semver@7.6.3: {} - - shebang-command@2.0.0: - dependencies: - shebang-regex: 3.0.0 - - shebang-regex@3.0.0: {} - - siginfo@2.0.0: {} - - signal-exit@3.0.7: {} - - signal-exit@4.1.0: {} - - sisteransi@1.0.5: {} - - slash@3.0.0: {} - - source-map-js@1.2.0: {} - - source-map-support@0.5.13: - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - - source-map-support@0.5.21: - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - optional: true - - source-map@0.6.1: {} - - sprintf-js@1.0.3: {} - - stack-utils@2.0.6: - dependencies: - escape-string-regexp: 2.0.0 - - stackback@0.0.2: {} - - std-env@3.7.0: {} - - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: - dependencies: - '@cosmjs/amino': 0.32.4 - '@cosmjs/encoding': 0.32.4 - '@cosmjs/math': 0.32.4 - '@cosmjs/proto-signing': 0.32.4 - '@cosmjs/stargate': 0.32.4 - '@cosmjs/tendermint-rpc': 0.32.4 - '@cosmjs/utils': 0.32.4 - '@cosmology/lcd': 0.13.4 - '@noble/hashes': 1.4.0 - bech32: 2.0.0 - cosmjs-types: 0.9.0 - transitivePeerDependencies: - - bufferutil - - debug - - utf-8-validate - - string-length@4.0.2: - dependencies: - char-regex: 1.0.2 - strip-ansi: 6.0.1 - - string-width@4.2.3: - dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 - - strip-ansi@6.0.1: - dependencies: - ansi-regex: 5.0.1 - - strip-bom@4.0.0: {} - - strip-final-newline@2.0.0: {} - - strip-final-newline@3.0.0: {} - - strip-json-comments@3.1.1: {} - - supports-color@5.5.0: - dependencies: - has-flag: 3.0.0 - - supports-color@7.2.0: - dependencies: - has-flag: 4.0.0 - - supports-color@8.1.1: - dependencies: - has-flag: 4.0.0 - - supports-preserve-symlinks-flag@1.0.0: {} - - symbol-observable@2.0.3: {} - - terser@5.31.3: - dependencies: - '@jridgewell/source-map': 0.3.6 - acorn: 8.12.1 - commander: 2.20.3 - source-map-support: 0.5.21 - optional: true - - test-exclude@6.0.0: - dependencies: - '@istanbuljs/schema': 0.1.3 - glob: 7.2.3 - minimatch: 3.1.2 - - tinybench@2.8.0: {} - - tinypool@1.0.0: {} - - tinyrainbow@1.2.0: {} - - tinyspy@3.0.0: {} - - tmpl@1.0.5: {} - - to-fast-properties@2.0.0: {} - - to-regex-range@5.0.1: - dependencies: - is-number: 7.0.0 - - ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3): - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.11 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.4 - '@types/node': 20.14.11 - acorn: 8.12.1 - acorn-walk: 8.3.3 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.5.3 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - optional: true - - type-detect@4.0.8: {} - - type-fest@0.21.3: {} - - typescript@5.5.3: {} - - undici-types@5.26.5: {} - - update-browserslist-db@1.1.0(browserslist@4.23.2): - dependencies: - browserslist: 4.23.2 - escalade: 3.1.2 - picocolors: 1.0.1 - - v8-compile-cache-lib@3.0.1: - optional: true - - v8-to-istanbul@9.3.0: - dependencies: - '@jridgewell/trace-mapping': 0.3.25 - '@types/istanbul-lib-coverage': 2.0.6 - convert-source-map: 2.0.0 - - vite-node@2.0.3(@types/node@20.14.11)(terser@5.31.3): - dependencies: - cac: 6.7.14 - debug: 4.3.5 - pathe: 1.1.2 - tinyrainbow: 1.2.0 - vite: 5.3.4(@types/node@20.14.11)(terser@5.31.3) - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - vite@5.3.4(@types/node@20.14.11)(terser@5.31.3): - dependencies: - esbuild: 0.21.5 - postcss: 8.4.39 - rollup: 4.18.1 - optionalDependencies: - '@types/node': 20.14.11 - fsevents: 2.3.3 - terser: 5.31.3 - - vitest@2.0.3(@types/node@20.14.11)(terser@5.31.3): - dependencies: - '@ampproject/remapping': 2.3.0 - '@vitest/expect': 2.0.3 - '@vitest/pretty-format': 2.0.3 - '@vitest/runner': 2.0.3 - '@vitest/snapshot': 2.0.3 - '@vitest/spy': 2.0.3 - '@vitest/utils': 2.0.3 - chai: 5.1.1 - debug: 4.3.5 - execa: 8.0.1 - magic-string: 0.30.10 - pathe: 1.1.2 - std-env: 3.7.0 - tinybench: 2.8.0 - tinypool: 1.0.0 - tinyrainbow: 1.2.0 - vite: 5.3.4(@types/node@20.14.11)(terser@5.31.3) - vite-node: 2.0.3(@types/node@20.14.11)(terser@5.31.3) - why-is-node-running: 2.3.0 - optionalDependencies: - '@types/node': 20.14.11 - transitivePeerDependencies: - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - walker@1.0.8: - dependencies: - makeerror: 1.0.12 - - which@2.0.2: - dependencies: - isexe: 2.0.0 - - why-is-node-running@2.3.0: - dependencies: - siginfo: 2.0.0 - stackback: 0.0.2 - - wrap-ansi@7.0.0: - dependencies: - ansi-styles: 4.3.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - - wrappy@1.0.2: {} - - write-file-atomic@4.0.2: - dependencies: - imurmurhash: 0.1.4 - signal-exit: 3.0.7 - - ws@7.5.10: {} - - xstream@11.14.0: - dependencies: - globalthis: 1.0.4 - symbol-observable: 2.0.3 - - y18n@5.0.8: {} - - yallist@3.1.1: {} - - yargs-parser@21.1.1: {} - - yargs@17.7.2: - dependencies: - cliui: 8.0.1 - escalade: 3.1.2 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 21.1.1 - - yn@3.1.1: - optional: true - - yocto-queue@0.1.0: {} diff --git a/dockernet/ts-tests/test/main.test.ts b/dockernet/ts-tests/test/main.test.ts deleted file mode 100644 index 2333575363..0000000000 --- a/dockernet/ts-tests/test/main.test.ts +++ /dev/null @@ -1,268 +0,0 @@ -import { Secp256k1HdWallet } from "@cosmjs/amino"; -import { GasPrice } from "@cosmjs/stargate"; -import { fromSeconds } from "@cosmjs/tendermint-rpc"; -import { - coinFromString, - convertBech32Prefix, - decToString, - StrideClient, -} from "stridejs"; -import { beforeAll, describe, expect, test } from "vitest"; -import { waitForChain } from "./utils"; - -const RPC_ENDPOINT = "http://localhost:26657"; -const HUB_RPC_ENDPOINT = "http://localhost:26557"; - -let accounts: { - user: StrideClient; // a normal account loaded with 100 STRD - admin: StrideClient; // the stride admin account loaded with 1000 STRD - val1: StrideClient; - val2: StrideClient; - val3: StrideClient; -}; - -let gaiaAccounts: { - user: StrideClient; // a normal account loaded with 100 ATOM -}; - -// init accounts and wait for chain to start -beforeAll(async () => { - console.log("setting up accounts..."); - - const mnemonics: { - name: "user" | "admin" | "val1" | "val2" | "val3"; - mnemonic: string; - }[] = [ - { - name: "user", - mnemonic: - "brief play describe burden half aim soccer carbon hope wait output play vacuum joke energy crucial output mimic cruise brother document rail anger leaf", - }, - { - name: "admin", - mnemonic: - "tone cause tribe this switch near host damage idle fragile antique tail soda alien depth write wool they rapid unfold body scan pledge soft", - }, - { - name: "val1", - mnemonic: - "close soup mirror crew erode defy knock trigger gather eyebrow tent farm gym gloom base lemon sleep weekend rich forget diagram hurt prize fly", - }, - { - name: "val2", - mnemonic: - "turkey miss hurry unable embark hospital kangaroo nuclear outside term toy fall buffalo book opinion such moral meadow wing olive camp sad metal banner", - }, - { - name: "val3", - mnemonic: - "tenant neck ask season exist hill churn rice convince shock modify evidence armor track army street stay light program harvest now settle feed wheat", - }, - ]; - - // @ts-expect-error - // init accounts as an empty object, then add the accounts in the loop - accounts = {}; - for (const { name, mnemonic } of mnemonics) { - // setup signer - // - // IMPORTANT: we're using Secp256k1HdWallet from @cosmjs/amino because sending amino txs tests both amino and direct. - // that's because the tx contains the direct encoding anyway, and also attaches a signature on the amino encoding. - // the mempool then converts from direct to amino to verify the signature. - // therefore if the signature verification passes, we can be sure that both amino and direct are supported. - const signer = await Secp256k1HdWallet.fromMnemonic(mnemonic, { - prefix: "stride", - }); - - // get signer address - const [{ address }] = await signer.getAccounts(); - - accounts[name] = await StrideClient.create(RPC_ENDPOINT, signer, address, { - gasPrice: GasPrice.fromString("0.025ustrd"), - broadcastPollIntervalMs: 50, - resolveIbcResponsesCheckIntervalMs: 50, - }); - - if (name === "user") { - const signer = await Secp256k1HdWallet.fromMnemonic(mnemonic); - - // get signer address - const [{ address }] = await signer.getAccounts(); - - gaiaAccounts = { - user: await StrideClient.create(HUB_RPC_ENDPOINT, signer, address, { - gasPrice: GasPrice.fromString("0.025uatom"), - broadcastPollIntervalMs: 50, - resolveIbcResponsesCheckIntervalMs: 50, - }), - }; - } - } - console.log("waiting for stride to start..."); - await waitForChain(accounts.user, "ustrd"); - - console.log("waiting for gaia to start..."); - await waitForChain(gaiaAccounts.user, "uatom"); -}); - -// time variables in seconds -const now = () => Math.floor(Date.now() / 1000); -const minute = 60; -const hour = 60 * minute; -const day = 24 * hour; - -describe("x/airdrop", () => { - test("MsgCreateAirdrop", async () => { - const stridejs = accounts.admin; - - const nowSec = now(); - const airdropId = String(nowSec); - - const msg = - stridejs.types.stride.airdrop.MessageComposer.withTypeUrl.createAirdrop({ - admin: stridejs.address, - airdropId: airdropId, - rewardDenom: "ustrd", - distributionStartDate: fromSeconds(now()), - distributionEndDate: fromSeconds(nowSec + 3 * day), - clawbackDate: fromSeconds(nowSec + 4 * day), - claimTypeDeadlineDate: fromSeconds(nowSec + 2 * day), - earlyClaimPenalty: decToString(0.5), - allocatorAddress: stridejs.address, - distributorAddress: stridejs.address, - linkerAddress: stridejs.address, - }); - - const tx = await stridejs.signAndBroadcast([msg], 2); - - if (tx.code !== 0) { - console.error(tx.rawLog); - } - expect(tx.code).toBe(0); - - const { id, earlyClaimPenalty } = - await stridejs.query.stride.airdrop.airdrop({ - id: airdropId, - }); - - expect(id).toBe(airdropId); - expect(earlyClaimPenalty).toBe("0.5"); - }); -}); - -describe("ibc", () => { - test("MsgTransfer", async () => { - const stridejs = accounts.user; - - const msg = - stridejs.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( - { - sourcePort: "transfer", - sourceChannel: "channel-0", - token: coinFromString("1ustrd"), - sender: stridejs.address, - receiver: convertBech32Prefix(stridejs.address, "cosmos"), - timeoutHeight: { - revisionNumber: 0n, - revisionHeight: 0n, - }, - timeoutTimestamp: BigInt( - `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes - ), - memo: "", - }, - ); - - const tx = await stridejs.signAndBroadcast([msg], 2); - if (tx.code !== 0) { - console.error(tx.rawLog); - } - expect(tx.code).toBe(0); - - const ibcAck = await tx.ibcResponses[0]; - expect(ibcAck.type).toBe("ack"); - expect(ibcAck.tx.code).toBe(0); - }, 30_000); -}); - -describe("x/stakeibc", () => { - test("batch undelegation happy path", async () => { - const strideClient = accounts.user; - const gaiaClient = gaiaAccounts.user; - - // get stATOM balance before - let { balances } = await strideClient.query.cosmos.bank.v1beta1.allBalances( - { - address: strideClient.address, - }, - ); - - const stAtomBalanceBefore = balances.find( - (coin) => coin.denom === "stuatom", - )?.amount; - - // get Gaia redemption rate - const { - hostZone: { redemptionRate }, - } = await strideClient.query.stride.stakeibc.hostZone({ - chainId: "GAIA", - }); - - // on Gaia, send ATOM to Stride and use autopilot to liquid stake - const amount = 1_000_000; - - let msg = - gaiaClient.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( - { - sourcePort: "transfer", - sourceChannel: "channel-0", - token: coinFromString(`${amount}uatom`), - sender: gaiaClient.address, - receiver: JSON.stringify({ - autopilot: { - stakeibc: { - stride_address: strideClient.address, - action: "LiquidStake", - }, - receiver: strideClient.address, - }, - }), - timeoutHeight: { - revisionNumber: 0n, - revisionHeight: 0n, - }, - timeoutTimestamp: BigInt( - `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes - ), - memo: "", - }, - ); - - let tx = await gaiaClient.signAndBroadcast([msg], 2); - if (tx.code !== 0) { - console.error(tx.rawLog); - } - expect(tx.code).toBe(0); - - // on Gaia, wait for the ibc ack - const ibcAck = await tx.ibcResponses[0]; - expect(ibcAck.type).toBe("ack"); - expect(ibcAck.tx.code).toBe(0); - - // get stATOM balance after - ({ balances } = await strideClient.query.cosmos.bank.v1beta1.allBalances({ - address: strideClient.address, - })); - - const stAtomBalanceAfter = balances.find( - (coin) => coin.denom === "stuatom", - )?.amount; - - // check expected stAtom balance using expectedStAtomAfter and redemptionRate - const expectedStAtomAfter = - Number(stAtomBalanceBefore ?? 0) + - Math.floor(amount / Number(redemptionRate)); // https://github.com/Stride-Labs/stride/blob/0cb59a10d/x/stakeibc/keeper/msg_server.go#L256 - - expect(Number(stAtomBalanceAfter ?? 0)).toBe(expectedStAtomAfter); - }, 120_000); -}); diff --git a/dockernet/ts-tests/test/utils.ts b/dockernet/ts-tests/test/utils.ts deleted file mode 100644 index 72cffdc598..0000000000 --- a/dockernet/ts-tests/test/utils.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { coinsFromString, StrideClient } from "stridejs"; - -/** - * Waits for the chain to start by continuously sending transactions until . - * - * @param {StrideClient} client The Stride client instance. - * @param {string} denom The denomination of the coins to send. - */ -export async function waitForChain( - client: StrideClient, - denom: string, -): Promise { - // the best way to ensure a chain is up is to successfully send a tx - - while (true) { - try { - const msg = - client.types.cosmos.bank.v1beta1.MessageComposer.withTypeUrl.send({ - fromAddress: client.address, - toAddress: client.address, - amount: coinsFromString(`1${denom}`), - }); - - const tx = await client.signAndBroadcast([msg], 2); - - if (tx.code == 0) { - break; - } - } catch (e) { - // signAndBroadcast might throw if the RPC is not up yet - } - } -} diff --git a/dockernet/ts-tests/vitest.config.ts b/dockernet/ts-tests/vitest.config.ts deleted file mode 100644 index c5659342b7..0000000000 --- a/dockernet/ts-tests/vitest.config.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { defineConfig } from "vitest/config"; - -export default defineConfig({ - test: { - globals: true, - environment: "node", - testTimeout: 30000, - hookTimeout: 30000, - pool: "forks", - poolOptions: { - forks: { - singleFork: true, - }, - }, - server: { - deps: { - inline: ["stridejs"], - }, - }, - }, - resolve: { - alias: { - stridejs: "stridejs/dist/esm", // Force ESM path - }, - }, -}); From 98470d7d58451fd44dad78fbf4cc8b0d77e83890 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:49:31 +0200 Subject: [PATCH 098/115] Removes query ID generation in Osmosis pool ICQ this is getting ignored anyway in https://github.com/Stride-Labs/stride/blob/5b470c214/x/interchainquery/keeper/queries.go#L32 --- x/icqoracle/keeper/icq.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index f2716443c4..547657f55f 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -79,9 +79,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( return errorsmod.Wrapf(err, "Error serializing tokenPrice '%+v' to bytes", tokenPrice) } - queryId := fmt.Sprintf("%s|%s|%s|%d", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, ctx.BlockHeight()) query := icqtypes.Query{ - Id: queryId, ChainId: params.OsmosisChainId, ConnectionId: params.OsmosisConnectionId, QueryType: icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, From 823fdab0932c38118f9aad573e057d664b6360c4 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:54:41 +0200 Subject: [PATCH 099/115] rename quoteDenom1/2 to commonQuoteDenom1/2 or something --- x/icqoracle/keeper/keeper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index cb79c56995..3e64f7bae5 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -180,9 +180,9 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu foundQuoteTokenZeroPrice := false // Find a common quote denom and calculate baseToken to quoteToken price - for quoteDenom1, baseTokenPrice := range baseTokenPrices { - for quoteDenom2, quoteTokenPrice := range quoteTokenPrices { - if quoteDenom1 == quoteDenom2 { + for commonQuoteDenom1, baseTokenPrice := range baseTokenPrices { + for commonQuoteDenom2, quoteTokenPrice := range quoteTokenPrices { + if commonQuoteDenom1 == commonQuoteDenom2 { foundCommonQuoteToken = true // Check that both prices are not stale From 210311ea3524ed1a4b8fec0d5d5f23c371fbc2f8 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:57:21 +0200 Subject: [PATCH 100/115] refactor fcfs bid price comparison logic for clarity Co-authored-by: sampocs --- x/auction/keeper/auction_type.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index 81d743c362..2b3d057eba 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -43,10 +43,10 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type // Apply MinPriceMultiplier bidsFloorPrice := price.Mul(auction.MinPriceMultiplier) + minPaymentRequired := bid.SellingTokenAmount.ToLegacyDec().Mul(bidsFloorPrice) // if paymentAmount < sellingAmount * bidsFloorPrice - if bid.PaymentTokenAmount.ToLegacyDec().LT(bid.SellingTokenAmount.ToLegacyDec(). - Mul(bidsFloorPrice)) { + if bid.PaymentTokenAmount.ToLegacyDec().LT(minPaymentRequired) { return fmt.Errorf("bid price too low: offered %s%s for %s%s, bids floor price is %s%s (price=%s %s/%s)", bid.PaymentTokenAmount.String(), auction.PaymentDenom, From 1af8e29692d8996e649f1d60fc8f87f456ef52ea Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 12:58:21 +0200 Subject: [PATCH 101/115] Update x/auction/keeper/auction_type.go Co-authored-by: sampocs --- x/auction/keeper/auction_type.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/auction_type.go index 2b3d057eba..a4a795dc17 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/auction_type.go @@ -52,7 +52,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type auction.PaymentDenom, bid.SellingTokenAmount.String(), auction.SellingDenom, - bid.SellingTokenAmount.ToLegacyDec().Mul(bidsFloorPrice).String(), + minPaymentRequired.String(), auction.PaymentDenom, bidsFloorPrice.String(), auction.PaymentDenom, From 07e77b046c28f6e42c1645253e2e451a21d0011e Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 17:29:21 +0200 Subject: [PATCH 102/115] fix tests after changes made in 98470d7d58451fd44dad78fbf4cc8b0d77e83890 --- x/icqoracle/keeper/icq_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index 59c741743e..55de0ed147 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -281,15 +281,6 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { s.Require().NoError(err) // Verify the captured query data - s.Require().NotEmpty(capturedQuery.Id, "query ID should not be empty") - expectedQueryId := fmt.Sprintf("%s|%s|%s|%d", - tokenPrice.BaseDenom, - tokenPrice.QuoteDenom, - tokenPrice.OsmosisPoolId, - s.Ctx.BlockHeight(), - ) - s.Require().Equal(expectedQueryId, capturedQuery.Id, "query ID should match expected format") - s.Require().Equal(params.OsmosisChainId, capturedQuery.ChainId) s.Require().Equal(params.OsmosisConnectionId, capturedQuery.ConnectionId) s.Require().Equal(icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, capturedQuery.QueryType) From a36b626e5cede3f14cd9a1d6ce15339318bd5f31 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 17:37:28 +0200 Subject: [PATCH 103/115] set block time explicitly in icqoracle tests this fixes regression in other tests that relied on the block time not being set - `TestQueryEpochInfos` (`x/epochs/keeper/grpc_query_test.go:24`) - `TestUpgrade` (`app/upgrades/v14/upgrades_test.go:274`) --- app/apptesting/test_helpers.go | 2 +- x/icqoracle/keeper/keeper_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/apptesting/test_helpers.go b/app/apptesting/test_helpers.go index 9d0ae7d079..1d4d47d0e7 100644 --- a/app/apptesting/test_helpers.go +++ b/app/apptesting/test_helpers.go @@ -81,7 +81,7 @@ type AppTestHelper struct { // AppTestHelper Constructor func (s *AppTestHelper) Setup() { s.App = app.InitStrideTestApp(true) - s.Ctx = s.App.BaseApp.NewContext(false, tmtypesproto.Header{Height: 1, ChainID: StrideChainID, Time: time.Now().UTC()}) + s.Ctx = s.App.BaseApp.NewContext(false, tmtypesproto.Header{Height: 1, ChainID: StrideChainID}) s.QueryHelper = &baseapp.QueryServiceTestHelper{ GRPCQueryRouter: s.App.GRPCQueryRouter(), Ctx: s.Ctx, diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index b79ff68381..998f5484bb 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "bytes" "testing" + "time" "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" @@ -36,6 +37,8 @@ func (s *KeeperTestSuite) SetupTest() { s.Setup() s.SetupMockICQKeeper() + s.Ctx = s.Ctx.WithBlockTime(time.Now().UTC()) + // Register ICQ callback s.icqCallbacks = s.App.ICQOracleKeeper.ICQCallbackHandler() s.icqCallbacks.RegisterICQCallbacks() From 373d5c8d01e20be24e207a73c600fd9dc341e5d0 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Sun, 2 Feb 2025 18:26:30 +0200 Subject: [PATCH 104/115] fix ci? Error: This request has been automatically failed because it uses a deprecated version of `actions/upload-artifact: v3`. Learn more: https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/ --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f83a439b1..78677fc65a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: - name: Compile stride run: make build - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: strided ${{ matrix.targetos }} ${{ matrix.arch }} path: build/strided From 058a06afc2b87e2cd9849730b1724c445cff2582 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 3 Feb 2025 21:31:14 +0200 Subject: [PATCH 105/115] icqoracle InitGenesis: don't modify any values from imported genesis --- x/icqoracle/keeper/genesis.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go index 051c0d710c..a25bc66baa 100644 --- a/x/icqoracle/keeper/genesis.go +++ b/x/icqoracle/keeper/genesis.go @@ -1,9 +1,6 @@ package keeper import ( - "time" - - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Stride-Labs/stride/v25/x/icqoracle/types" @@ -17,10 +14,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { } for _, tokenPrice := range genState.TokenPrices { - tokenPrice.SpotPrice = math.LegacyZeroDec() - tokenPrice.UpdatedAt = time.Time{} - tokenPrice.QueryInProgress = false - if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { panic(err) } From 0452533dc825d9a11bd1c85dfd8adb22888be79a Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 3 Feb 2025 22:17:18 +0200 Subject: [PATCH 106/115] icqoracle queries: add human readable token denoms --- app/app.go | 2 + proto/stride/icqoracle/query.proto | 44 +- x/icqoracle/keeper/keeper.go | 15 +- x/icqoracle/keeper/query.go | 51 +- x/icqoracle/keeper/query_test.go | 2 +- x/icqoracle/types/expected_keepers.go | 8 + x/icqoracle/types/query.pb.go | 813 ++++++++++++++++++-- x/stakeibc/keeper/reward_allocation.go | 5 +- x/stakeibc/keeper/reward_allocation_test.go | 1 + 9 files changed, 879 insertions(+), 62 deletions(-) diff --git a/app/app.go b/app/app.go index 8988aea745..da24b2d843 100644 --- a/app/app.go +++ b/app/app.go @@ -784,6 +784,8 @@ func NewStrideApp( app.ICQOracleKeeper = *icqoraclekeeper.NewKeeper( appCodec, keys[icqoracletypes.StoreKey], + &app.InterchainqueryKeeper, + app.TransferKeeper, ) icqOracleModule := icqoracle.NewAppModule(appCodec, app.ICQOracleKeeper) diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index ec031261c0..6b352e1ea4 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -1,10 +1,11 @@ syntax = "proto3"; package stride.icqoracle; -import "stride/icqoracle/icqoracle.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/protobuf/timestamp.proto"; +import "stride/icqoracle/icqoracle.proto"; option go_package = "github.com/Stride-Labs/stride/v25/x/icqoracle/types"; @@ -43,7 +44,7 @@ message QueryTokenPriceRequest { // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC // method message QueryTokenPriceResponse { - TokenPrice token_price = 1 [ (gogoproto.nullable) = false ]; + TokenPriceResponse token_price = 1 [ (gogoproto.nullable) = false ]; } // QueryTokenPricesRequest is the request type for the Query/TokenPrices RPC @@ -55,7 +56,7 @@ message QueryTokenPricesRequest { // QueryTokenPricesResponse is the response type for the Query/TokenPrices RPC // method message QueryTokenPricesResponse { - repeated TokenPrice token_prices = 1 [ (gogoproto.nullable) = false ]; + repeated TokenPriceResponse token_prices = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -81,4 +82,39 @@ message QueryTokenPriceForQuoteDenomResponse { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; +} + +// TokenPriceResponse adds human readable info on to of TokenPrice +message TokenPriceResponse { + // If IBC token, base denom unwrapped (e.g. ibc/... -> uatom) + string base_denom_unwrapped = 1; + // If IBC token, Quote denom unwrapped (e.g. ibc/... -> uatom) + string quote_denom_unwrapped = 2; + // Base denom on Stride, can be IBC denom + string base_denom = 3; + // Quote denom on Stride, can be IBC denom + string quote_denom = 4; + // Decimals of base token, used for normalizing price feed from Osmosis + int64 base_denom_decimals = 5; + // Decimals of quote token, used for normalizing price feed from Osmosis + int64 quote_denom_decimals = 6; + // Base denom on Osmosis + string osmosis_base_denom = 7; + // Quote denom on Osmosis + string osmosis_quote_denom = 8; + // Pool ID on Osmosis + string osmosis_pool_id = 9; + + // Spot price of base_denom denominated in quote_denom + string spot_price = 10 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + // Last update timestamp + google.protobuf.Timestamp updated_at = 11 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + + // Whether there is a spot price query currently in progress + bool query_in_progress = 12; } \ No newline at end of file diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 3e64f7bae5..a6cc681430 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -15,18 +15,23 @@ import ( ) type Keeper struct { - cdc codec.Codec - storeKey storetypes.StoreKey - IcqKeeper types.IcqKeeper + cdc codec.Codec + storeKey storetypes.StoreKey + IcqKeeper types.IcqKeeper + ibcTransferKeeper types.IbcTransferKeeper } func NewKeeper( cdc codec.Codec, storeKey storetypes.StoreKey, + icqKeeper types.IcqKeeper, + ibcTransferKeeper types.IbcTransferKeeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, + cdc: cdc, + storeKey: storeKey, + IcqKeeper: icqKeeper, + ibcTransferKeeper: ibcTransferKeeper, } } diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index 3f1a9fd6b4..6da1cd7a67 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -2,12 +2,15 @@ package keeper import ( "context" + "strings" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "github.com/Stride-Labs/stride/v25/x/icqoracle/types" ) @@ -21,13 +24,13 @@ func (k Keeper) TokenPrice(goCtx context.Context, req *types.QueryTokenPriceRequ ctx := sdk.UnwrapSDKContext(goCtx) - price, err := k.GetTokenPrice(ctx, req.BaseDenom, req.QuoteDenom, req.PoolId) + tokenPrice, err := k.GetTokenPrice(ctx, req.BaseDenom, req.QuoteDenom, req.PoolId) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) } return &types.QueryTokenPriceResponse{ - TokenPrice: price, + TokenPrice: k.TokenPriceToTokenPriceResponse(ctx, tokenPrice)[0], }, nil } @@ -44,7 +47,7 @@ func (k Keeper) TokenPrices(goCtx context.Context, req *types.QueryTokenPricesRe prices := k.GetAllTokenPrices(ctx) return &types.QueryTokenPricesResponse{ - TokenPrices: prices, + TokenPrices: k.TokenPriceToTokenPriceResponse(ctx, prices...), }, nil } @@ -83,3 +86,45 @@ func (k Keeper) TokenPriceForQuoteDenom(goCtx context.Context, req *types.QueryT Price: price, }, nil } + +func (k Keeper) unwrapIBCDenom(ctx sdk.Context, denom string) string { + if !strings.HasPrefix(denom, "ibc/") { + return denom + } + + hash, err := ibctransfertypes.ParseHexHash(strings.TrimPrefix(denom, "ibc/")) + if err == nil { + denomTrace, found := k.ibcTransferKeeper.GetDenomTrace(ctx, hash) + if found { + return denomTrace.BaseDenom + } + } + return denom +} + +// TokenPriceToTokenPriceResponse converts TokenPrices to TokenPriceResponses format +func (k Keeper) TokenPriceToTokenPriceResponse(ctx sdk.Context, tokenPrices ...types.TokenPrice) []types.TokenPriceResponse { + responses := make([]types.TokenPriceResponse, len(tokenPrices)) + + for i, tokenPrice := range tokenPrices { + baseDenomUnwrapped := k.unwrapIBCDenom(ctx, tokenPrice.BaseDenom) + quoteDenomUnwrapped := k.unwrapIBCDenom(ctx, tokenPrice.QuoteDenom) + + responses[i] = types.TokenPriceResponse{ + BaseDenomUnwrapped: baseDenomUnwrapped, + QuoteDenomUnwrapped: quoteDenomUnwrapped, + BaseDenom: tokenPrice.BaseDenom, + QuoteDenom: tokenPrice.QuoteDenom, + BaseDenomDecimals: tokenPrice.BaseDenomDecimals, + QuoteDenomDecimals: tokenPrice.QuoteDenomDecimals, + OsmosisBaseDenom: tokenPrice.OsmosisBaseDenom, + OsmosisQuoteDenom: tokenPrice.OsmosisQuoteDenom, + OsmosisPoolId: tokenPrice.OsmosisPoolId, + SpotPrice: tokenPrice.SpotPrice, + UpdatedAt: tokenPrice.UpdatedAt, + QueryInProgress: tokenPrice.QueryInProgress, + } + } + + return responses +} diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index 7e1fcc05ca..7851879239 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -75,7 +75,7 @@ func (s *KeeperTestSuite) TestQueryTokenPrices() { req := &types.QueryTokenPricesRequest{} resp, err := s.App.ICQOracleKeeper.TokenPrices(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err, "no error expected when querying all token prices") - s.Require().Equal(expectedPrices, resp.TokenPrices, "token prices") + s.Require().Equal(s.App.ICQOracleKeeper.TokenPriceToTokenPriceResponse(s.Ctx, expectedPrices...), resp.TokenPrices, "token prices") // Query with invalid request _, err = s.App.ICQOracleKeeper.TokenPrices(sdk.WrapSDKContext(s.Ctx), nil) diff --git a/x/icqoracle/types/expected_keepers.go b/x/icqoracle/types/expected_keepers.go index 72a872a6fb..e35b6e6493 100644 --- a/x/icqoracle/types/expected_keepers.go +++ b/x/icqoracle/types/expected_keepers.go @@ -3,6 +3,9 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + tmbytes "github.com/cometbft/cometbft/libs/bytes" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "github.com/Stride-Labs/stride/v25/x/interchainquery/types" ) @@ -10,3 +13,8 @@ import ( type IcqKeeper interface { SubmitICQRequest(ctx sdk.Context, icqtypes types.Query, forceUnique bool) error } + +// IbcTransferKeeper defines the expected interface needed to convert an ibc token hash to its denom on the source chain. +type IbcTransferKeeper interface { + GetDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (ibctransfertypes.DenomTrace, bool) +} diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 096480b3e5..14b223d523 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -5,12 +5,15 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + _ "github.com/cosmos/gogoproto/types" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -18,12 +21,14 @@ import ( 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. @@ -96,7 +101,7 @@ func (m *QueryTokenPriceRequest) GetPoolId() string { // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC // method type QueryTokenPriceResponse struct { - TokenPrice TokenPrice `protobuf:"bytes,1,opt,name=token_price,json=tokenPrice,proto3" json:"token_price"` + TokenPrice TokenPriceResponse `protobuf:"bytes,1,opt,name=token_price,json=tokenPrice,proto3" json:"token_price"` } func (m *QueryTokenPriceResponse) Reset() { *m = QueryTokenPriceResponse{} } @@ -132,11 +137,11 @@ func (m *QueryTokenPriceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTokenPriceResponse proto.InternalMessageInfo -func (m *QueryTokenPriceResponse) GetTokenPrice() TokenPrice { +func (m *QueryTokenPriceResponse) GetTokenPrice() TokenPriceResponse { if m != nil { return m.TokenPrice } - return TokenPrice{} + return TokenPriceResponse{} } // QueryTokenPricesRequest is the request type for the Query/TokenPrices RPC @@ -188,8 +193,8 @@ func (m *QueryTokenPricesRequest) GetPagination() *query.PageRequest { // QueryTokenPricesResponse is the response type for the Query/TokenPrices RPC // method type QueryTokenPricesResponse struct { - TokenPrices []TokenPrice `protobuf:"bytes,1,rep,name=token_prices,json=tokenPrices,proto3" json:"token_prices"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + TokenPrices []TokenPriceResponse `protobuf:"bytes,1,rep,name=token_prices,json=tokenPrices,proto3" json:"token_prices"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryTokenPricesResponse) Reset() { *m = QueryTokenPricesResponse{} } @@ -225,7 +230,7 @@ func (m *QueryTokenPricesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTokenPricesResponse proto.InternalMessageInfo -func (m *QueryTokenPricesResponse) GetTokenPrices() []TokenPrice { +func (m *QueryTokenPricesResponse) GetTokenPrices() []TokenPriceResponse { if m != nil { return m.TokenPrices } @@ -414,6 +419,144 @@ func (m *QueryTokenPriceForQuoteDenomResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTokenPriceForQuoteDenomResponse proto.InternalMessageInfo +// TokenPriceResponse adds human readable info on to of TokenPrice +type TokenPriceResponse struct { + // If IBC token, base denom unwrapped (e.g. ibc/... -> uatom) + BaseDenomUnwrapped string `protobuf:"bytes,1,opt,name=base_denom_unwrapped,json=baseDenomUnwrapped,proto3" json:"base_denom_unwrapped,omitempty"` + // If IBC token, Quote denom unwrapped (e.g. ibc/... -> uatom) + QuoteDenomUnwrapped string `protobuf:"bytes,2,opt,name=quote_denom_unwrapped,json=quoteDenomUnwrapped,proto3" json:"quote_denom_unwrapped,omitempty"` + // Base denom on Stride, can be IBC denom + BaseDenom string `protobuf:"bytes,3,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` + // Quote denom on Stride, can be IBC denom + QuoteDenom string `protobuf:"bytes,4,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` + // Decimals of base token, used for normalizing price feed from Osmosis + BaseDenomDecimals int64 `protobuf:"varint,5,opt,name=base_denom_decimals,json=baseDenomDecimals,proto3" json:"base_denom_decimals,omitempty"` + // Decimals of quote token, used for normalizing price feed from Osmosis + QuoteDenomDecimals int64 `protobuf:"varint,6,opt,name=quote_denom_decimals,json=quoteDenomDecimals,proto3" json:"quote_denom_decimals,omitempty"` + // Base denom on Osmosis + OsmosisBaseDenom string `protobuf:"bytes,7,opt,name=osmosis_base_denom,json=osmosisBaseDenom,proto3" json:"osmosis_base_denom,omitempty"` + // Quote denom on Osmosis + OsmosisQuoteDenom string `protobuf:"bytes,8,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` + // Pool ID on Osmosis + OsmosisPoolId string `protobuf:"bytes,9,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + // Spot price of base_denom denominated in quote_denom + SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,10,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` + // Last update timestamp + UpdatedAt time.Time `protobuf:"bytes,11,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + // Whether there is a spot price query currently in progress + QueryInProgress bool `protobuf:"varint,12,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` +} + +func (m *TokenPriceResponse) Reset() { *m = TokenPriceResponse{} } +func (m *TokenPriceResponse) String() string { return proto.CompactTextString(m) } +func (*TokenPriceResponse) ProtoMessage() {} +func (*TokenPriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_51a2bacbcf1e1cb4, []int{8} +} +func (m *TokenPriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TokenPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TokenPriceResponse.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 *TokenPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_TokenPriceResponse.Merge(m, src) +} +func (m *TokenPriceResponse) XXX_Size() int { + return m.Size() +} +func (m *TokenPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_TokenPriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_TokenPriceResponse proto.InternalMessageInfo + +func (m *TokenPriceResponse) GetBaseDenomUnwrapped() string { + if m != nil { + return m.BaseDenomUnwrapped + } + return "" +} + +func (m *TokenPriceResponse) GetQuoteDenomUnwrapped() string { + if m != nil { + return m.QuoteDenomUnwrapped + } + return "" +} + +func (m *TokenPriceResponse) GetBaseDenom() string { + if m != nil { + return m.BaseDenom + } + return "" +} + +func (m *TokenPriceResponse) GetQuoteDenom() string { + if m != nil { + return m.QuoteDenom + } + return "" +} + +func (m *TokenPriceResponse) GetBaseDenomDecimals() int64 { + if m != nil { + return m.BaseDenomDecimals + } + return 0 +} + +func (m *TokenPriceResponse) GetQuoteDenomDecimals() int64 { + if m != nil { + return m.QuoteDenomDecimals + } + return 0 +} + +func (m *TokenPriceResponse) GetOsmosisBaseDenom() string { + if m != nil { + return m.OsmosisBaseDenom + } + return "" +} + +func (m *TokenPriceResponse) GetOsmosisQuoteDenom() string { + if m != nil { + return m.OsmosisQuoteDenom + } + return "" +} + +func (m *TokenPriceResponse) GetOsmosisPoolId() string { + if m != nil { + return m.OsmosisPoolId + } + return "" +} + +func (m *TokenPriceResponse) GetUpdatedAt() time.Time { + if m != nil { + return m.UpdatedAt + } + return time.Time{} +} + +func (m *TokenPriceResponse) GetQueryInProgress() bool { + if m != nil { + return m.QueryInProgress + } + return false +} + func init() { proto.RegisterType((*QueryTokenPriceRequest)(nil), "stride.icqoracle.QueryTokenPriceRequest") proto.RegisterType((*QueryTokenPriceResponse)(nil), "stride.icqoracle.QueryTokenPriceResponse") @@ -423,51 +566,68 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "stride.icqoracle.QueryParamsResponse") proto.RegisterType((*QueryTokenPriceForQuoteDenomRequest)(nil), "stride.icqoracle.QueryTokenPriceForQuoteDenomRequest") proto.RegisterType((*QueryTokenPriceForQuoteDenomResponse)(nil), "stride.icqoracle.QueryTokenPriceForQuoteDenomResponse") + proto.RegisterType((*TokenPriceResponse)(nil), "stride.icqoracle.TokenPriceResponse") } func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 622 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0x8e, 0xfb, 0x13, 0xd4, 0x09, 0x07, 0xb4, 0x54, 0xc4, 0x58, 0xa9, 0x13, 0x99, 0xb6, 0x94, - 0x4a, 0xf5, 0xaa, 0xa9, 0xda, 0x07, 0x08, 0xa1, 0x08, 0x89, 0x4a, 0x69, 0xe0, 0xc4, 0x81, 0x68, - 0xe3, 0xac, 0x8c, 0xd5, 0xc4, 0xeb, 0x78, 0x9d, 0x42, 0xaf, 0x3d, 0x70, 0x46, 0xe2, 0x2d, 0xb8, - 0xf0, 0x0a, 0x1c, 0x7b, 0xac, 0xc4, 0x05, 0x71, 0xa8, 0x50, 0xc2, 0x83, 0x20, 0xef, 0xae, 0xf3, - 0x53, 0x27, 0x24, 0x48, 0x9c, 0xb2, 0x99, 0xf9, 0x66, 0xe6, 0x9b, 0x6f, 0x3f, 0x2f, 0x14, 0x78, - 0x14, 0x7a, 0x2d, 0x8a, 0x3d, 0xa7, 0xcb, 0x42, 0xe2, 0xb4, 0x29, 0xee, 0xf6, 0x68, 0x78, 0x61, - 0x07, 0x21, 0x8b, 0x18, 0xba, 0x27, 0xb3, 0xf6, 0x30, 0x6b, 0x94, 0x52, 0xf8, 0xe1, 0x49, 0xd6, - 0x18, 0xeb, 0x2e, 0x73, 0x99, 0x38, 0xe2, 0xf8, 0xa4, 0xa2, 0x05, 0x97, 0x31, 0xb7, 0x4d, 0x31, - 0x09, 0x3c, 0x4c, 0x7c, 0x9f, 0x45, 0x24, 0xf2, 0x98, 0xcf, 0x55, 0x76, 0xd7, 0x61, 0xbc, 0xc3, - 0x38, 0x6e, 0x12, 0xae, 0x08, 0xe0, 0xf3, 0xfd, 0x26, 0x8d, 0xc8, 0x3e, 0x0e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 0x04, 0xd7, 0x1a, 0x09, 0x49, 0x27, 0x91, 0xc2, 0x3a, 0x81, 0xfb, 0x13, 0x51, - 0x45, 0xfe, 0x08, 0xb2, 0x81, 0x88, 0x28, 0x75, 0xf4, 0x34, 0x6d, 0x59, 0xa1, 0x28, 0x2b, 0xb4, - 0x45, 0xe1, 0xd1, 0x2d, 0x41, 0x8e, 0x59, 0x78, 0x3a, 0x74, 0xc3, 0x7f, 0x32, 0x95, 0xd5, 0x86, - 0xcd, 0xbf, 0x8f, 0x51, 0x6b, 0x54, 0x61, 0x75, 0x64, 0xa1, 0xb5, 0x8a, 0x1d, 0x73, 0xfd, 0x79, - 0x53, 0xdc, 0x76, 0xbd, 0xe8, 0x5d, 0xaf, 0x69, 0x3b, 0xac, 0x83, 0xd5, 0x47, 0x22, 0x7f, 0xf6, - 0x78, 0xeb, 0x0c, 0x47, 0x17, 0x01, 0xe5, 0x76, 0x95, 0x3a, 0x75, 0x59, 0x5c, 0xfe, 0xb6, 0x02, - 0xab, 0x62, 0x1c, 0xba, 0xd4, 0x00, 0x46, 0x33, 0xd1, 0x4e, 0x5a, 0x95, 0xe9, 0x5f, 0x91, 0xf1, - 0x64, 0x01, 0xa4, 0xe4, 0x6c, 0x15, 0x2f, 0xbf, 0xff, 0xfe, 0xbc, 0xf4, 0x10, 0xe5, 0x71, 0xea, - 0x55, 0x10, 0x74, 0xd0, 0x47, 0x0d, 0x72, 0x63, 0x86, 0x43, 0xf3, 0x7b, 0x27, 0xb7, 0x6d, 0xec, - 0x2e, 0x02, 0x55, 0x3c, 0x4a, 0x82, 0x87, 0x81, 0xf4, 0x19, 0x3c, 0x38, 0x7a, 0x0f, 0x59, 0x69, - 0x02, 0xb4, 0x39, 0xa3, 0xef, 0x84, 0xd7, 0x8c, 0xad, 0x39, 0xa8, 0x05, 0x06, 0xcb, 0x71, 0x5f, - 0x35, 0xc8, 0xcf, 0xb8, 0x7a, 0x74, 0x38, 0x77, 0xc5, 0x69, 0x8e, 0x34, 0x8e, 0xfe, 0xb5, 0x4c, - 0x91, 0xdd, 0x12, 0x64, 0x8b, 0x68, 0x03, 0x4f, 0x79, 0xf3, 0x63, 0x0b, 0x0b, 0xad, 0x2a, 0x27, - 0x57, 0x7d, 0x53, 0xbb, 0xee, 0x9b, 0xda, 0xaf, 0xbe, 0xa9, 0x7d, 0x1a, 0x98, 0x99, 0xeb, 0x81, - 0x99, 0xf9, 0x31, 0x30, 0x33, 0x6f, 0x0e, 0xc6, 0xbc, 0xf8, 0x4a, 0xb4, 0xd8, 0x7b, 0x49, 0x9a, - 0x3c, 0x69, 0x77, 0x5e, 0x3e, 0xc4, 0x1f, 0xc6, 0x9a, 0x0a, 0x73, 0x36, 0xb3, 0xe2, 0xd5, 0x3e, - 0xf8, 0x13, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xd0, 0xaa, 0x7e, 0x69, 0x06, 0x00, 0x00, + // 880 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xce, 0xe6, 0xc3, 0x8d, 0x5f, 0x17, 0xb5, 0x99, 0x04, 0xb2, 0x98, 0xd6, 0xb6, 0xb6, 0x69, + 0x08, 0x11, 0x9d, 0xa5, 0xa9, 0xda, 0x3b, 0x26, 0x2a, 0xaa, 0x68, 0x24, 0x77, 0x29, 0x17, 0x2e, + 0xd6, 0x78, 0x77, 0xba, 0x5d, 0xc5, 0xbb, 0xb3, 0xde, 0x19, 0xb7, 0xe4, 0xda, 0x03, 0xe7, 0x4a, + 0xfc, 0x10, 0x24, 0x7e, 0x01, 0xc7, 0x1e, 0x2b, 0x71, 0x00, 0x71, 0x28, 0x28, 0xe1, 0x87, 0xa0, + 0xf9, 0xd8, 0x0f, 0x77, 0x1d, 0x9c, 0x48, 0x9c, 0xba, 0x7e, 0x3f, 0x9f, 0xe7, 0x7d, 0xdf, 0x79, + 0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7, 0x69, 0xc7, 0x7a, 0x7d, 0xd6, 0x59, 0x7a, 0x7b, 0xd6, + 0x59, 0xfa, 0xe3, 0xac, 0xb3, 0xf4, 0xfd, 0xbd, 0x8a, 0xca, 0x7d, 0xab, 0x4a, 0xdc, 0x79, 0x4c, + 0x46, 0x3c, 0x2f, 0xf7, 0xe2, 0xe0, 0xbe, 0xfb, 0x43, 0xa5, 0xa8, 0x92, 0xbd, 0x51, 0x43, 0x9d, + 0xf9, 0xbd, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xb6, 0x1f, 0xa4, 0xc3, 0xf4, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -953,6 +1113,116 @@ func (m *QueryTokenPriceForQuoteDenomResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *TokenPriceResponse) 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 *TokenPriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryInProgress { + i-- + if m.QueryInProgress { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x60 + } + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintQuery(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x5a + { + size := m.SpotPrice.Size() + i -= size + if _, err := m.SpotPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if len(m.OsmosisPoolId) > 0 { + i -= len(m.OsmosisPoolId) + copy(dAtA[i:], m.OsmosisPoolId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.OsmosisPoolId))) + i-- + dAtA[i] = 0x4a + } + if len(m.OsmosisQuoteDenom) > 0 { + i -= len(m.OsmosisQuoteDenom) + copy(dAtA[i:], m.OsmosisQuoteDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.OsmosisQuoteDenom))) + i-- + dAtA[i] = 0x42 + } + if len(m.OsmosisBaseDenom) > 0 { + i -= len(m.OsmosisBaseDenom) + copy(dAtA[i:], m.OsmosisBaseDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.OsmosisBaseDenom))) + i-- + dAtA[i] = 0x3a + } + if m.QuoteDenomDecimals != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QuoteDenomDecimals)) + i-- + dAtA[i] = 0x30 + } + if m.BaseDenomDecimals != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BaseDenomDecimals)) + i-- + dAtA[i] = 0x28 + } + if len(m.QuoteDenom) > 0 { + i -= len(m.QuoteDenom) + copy(dAtA[i:], m.QuoteDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteDenom))) + i-- + dAtA[i] = 0x22 + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.QuoteDenomUnwrapped) > 0 { + i -= len(m.QuoteDenomUnwrapped) + copy(dAtA[i:], m.QuoteDenomUnwrapped) + i = encodeVarintQuery(dAtA, i, uint64(len(m.QuoteDenomUnwrapped))) + i-- + dAtA[i] = 0x12 + } + if len(m.BaseDenomUnwrapped) > 0 { + i -= len(m.BaseDenomUnwrapped) + copy(dAtA[i:], m.BaseDenomUnwrapped) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BaseDenomUnwrapped))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1076,6 +1346,56 @@ func (m *QueryTokenPriceForQuoteDenomResponse) Size() (n int) { return n } +func (m *TokenPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BaseDenomUnwrapped) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteDenomUnwrapped) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.BaseDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.QuoteDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BaseDenomDecimals != 0 { + n += 1 + sovQuery(uint64(m.BaseDenomDecimals)) + } + if m.QuoteDenomDecimals != 0 { + n += 1 + sovQuery(uint64(m.QuoteDenomDecimals)) + } + l = len(m.OsmosisBaseDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.OsmosisQuoteDenom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.OsmosisPoolId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.SpotPrice.Size() + n += 1 + l + sovQuery(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) + n += 1 + l + sovQuery(uint64(l)) + if m.QueryInProgress { + n += 2 + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1455,7 +1775,7 @@ func (m *QueryTokenPricesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TokenPrices = append(m.TokenPrices, TokenPrice{}) + m.TokenPrices = append(m.TokenPrices, TokenPriceResponse{}) if err := m.TokenPrices[len(m.TokenPrices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1848,6 +2168,405 @@ func (m *QueryTokenPriceForQuoteDenomResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *TokenPriceResponse) 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: TokenPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TokenPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenomUnwrapped", 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.BaseDenomUnwrapped = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenomUnwrapped", 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.QuoteDenomUnwrapped = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", 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.BaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenom", 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.QuoteDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenomDecimals", wireType) + } + m.BaseDenomDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BaseDenomDecimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QuoteDenomDecimals", wireType) + } + m.QuoteDenomDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QuoteDenomDecimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisBaseDenom", 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.OsmosisBaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisQuoteDenom", 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.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", 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.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", 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.SpotPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", 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_cosmos_gogoproto_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", 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.QueryInProgress = 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/stakeibc/keeper/reward_allocation.go b/x/stakeibc/keeper/reward_allocation.go index c863319cdd..7e576b6c51 100644 --- a/x/stakeibc/keeper/reward_allocation.go +++ b/x/stakeibc/keeper/reward_allocation.go @@ -1,10 +1,11 @@ package keeper import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "fmt" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + sdk "github.com/cosmos/cosmos-sdk/types" + auctiontypes "github.com/Stride-Labs/stride/v25/x/auction/types" "github.com/Stride-Labs/stride/v25/x/stakeibc/types" ) diff --git a/x/stakeibc/keeper/reward_allocation_test.go b/x/stakeibc/keeper/reward_allocation_test.go index 225b61d2b8..75c98a1cc6 100644 --- a/x/stakeibc/keeper/reward_allocation_test.go +++ b/x/stakeibc/keeper/reward_allocation_test.go @@ -15,6 +15,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/stretchr/testify/suite" + auctiontypes "github.com/Stride-Labs/stride/v25/x/auction/types" epochtypes "github.com/Stride-Labs/stride/v25/x/epochs/types" recordtypes "github.com/Stride-Labs/stride/v25/x/records/types" stakeibctypes "github.com/Stride-Labs/stride/v25/x/stakeibc/types" From ded88301e12e30c425c47f02f657073bf0ed6e63 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 3 Feb 2025 22:23:14 +0200 Subject: [PATCH 107/115] Renames TokenPriceQueryKey to TokenPriceKey --- x/icqoracle/keeper/keeper.go | 6 +++--- x/icqoracle/types/keys.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index a6cc681430..6b79185fa1 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -42,7 +42,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // SetTokenPrice stores price query for a token func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceQueryKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) bz, err := k.cdc.Marshal(&tokenPrice) if err != nil { @@ -56,7 +56,7 @@ func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) erro // RemoveTokenPrice removes price query for a token func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceQueryKey(baseDenom, quoteDenom, osmosisPoolId) + key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) store.Delete(key) } @@ -78,7 +78,7 @@ func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, // GetTokenPrice retrieves price data for a token func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) (types.TokenPrice, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceQueryKey(baseDenom, quoteDenom, osmosisPoolId) + key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) bz := store.Get(key) if bz == nil { diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index db3fc06fe0..044e1063a9 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -17,7 +17,7 @@ var ( PriceQueryPrefix = []byte("pricequery") ) -func TokenPriceQueryKey(baseDenom, quoteDenom, poolId string) []byte { +func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { return []byte(fmt.Sprintf("%s|%s|%s", baseDenom, quoteDenom, poolId)) } From ea5aaefef2dd9998710b9ae9cbb10f130d4d4356 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Mon, 3 Feb 2025 22:57:35 +0200 Subject: [PATCH 108/115] remove redundant error logging --- x/icqoracle/keeper/icq.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 547657f55f..b7c09fa587 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -63,19 +63,16 @@ func (k Keeper) SubmitOsmosisClPoolICQ( params, err := k.GetParams(ctx) if err != nil { - k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error getting module params: %s", err.Error())) return errorsmod.Wrapf(err, "Error getting module params") } osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) if err != nil { - k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error converting osmosis pool id '%s' to uint64, error '%s'", tokenPrice.OsmosisPoolId, err.Error())) return errorsmod.Wrapf(err, "Error converting osmosis pool id '%s' to uint64", tokenPrice.OsmosisPoolId) } tokenPriceBz, err := k.cdc.Marshal(&tokenPrice) if err != nil { - k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error serializing tokenPrice '%+v' to bytes, error '%s'", tokenPrice, err.Error())) return errorsmod.Wrapf(err, "Error serializing tokenPrice '%+v' to bytes", tokenPrice) } @@ -91,12 +88,10 @@ func (k Keeper) SubmitOsmosisClPoolICQ( TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } if err := k.IcqKeeper.SubmitICQRequest(ctx, query, true); err != nil { - k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error submitting OsmosisClPool ICQ, error '%s'", err.Error())) return errorsmod.Wrapf(err, "Error submitting OsmosisClPool ICQ") } if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, true); err != nil { - k.Logger(ctx).Error(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Error updating queryInProgress=true, error '%s'", err.Error())) return errorsmod.Wrapf(err, "Error updating queryInProgress=true") } From 62d02bd28618e5fc5bfefffea5766aeb050da6bf Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Feb 2025 08:18:40 -0600 Subject: [PATCH 109/115] v26 upgrade test (#1343) --- app/upgrades.go | 11 +++++++++++ app/upgrades/v26/upgrades.go | 19 +++++++++++++------ app/upgrades/v26/upgrades_test.go | 11 +++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 242290aaff..fbc1664c8c 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -35,6 +35,7 @@ import ( v23 "github.com/Stride-Labs/stride/v25/app/upgrades/v23" v24 "github.com/Stride-Labs/stride/v25/app/upgrades/v24" v25 "github.com/Stride-Labs/stride/v25/app/upgrades/v25" + v26 "github.com/Stride-Labs/stride/v25/app/upgrades/v26" v3 "github.com/Stride-Labs/stride/v25/app/upgrades/v3" v4 "github.com/Stride-Labs/stride/v25/app/upgrades/v4" v5 "github.com/Stride-Labs/stride/v25/app/upgrades/v5" @@ -341,6 +342,16 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) { ), ) + // v26 upgrade handler + app.UpgradeKeeper.SetUpgradeHandler( + v26.UpgradeName, + v26.CreateUpgradeHandler( + app.mm, + app.configurator, + app.ICQOracleKeeper, + ), + ) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err)) diff --git a/app/upgrades/v26/upgrades.go b/app/upgrades/v26/upgrades.go index 68120bde2d..632c8d4117 100644 --- a/app/upgrades/v26/upgrades.go +++ b/app/upgrades/v26/upgrades.go @@ -11,7 +11,15 @@ import ( icqoracletypes "github.com/Stride-Labs/stride/v25/x/icqoracle/types" ) -var UpgradeName = "v26" +var ( + UpgradeName = "v26" + + OsmosisChainId = "osmosis-1" + OsmosisConnectionId = "connection-2" + + ICQOracleUpdateIntervalSec = uint64(5 * 60) // 5 min + ICQOraclePriceExpirationTimeoutSec = uint64(15 * 60) // 15 min +) // CreateUpgradeHandler creates an SDK upgrade handler for v23 func CreateUpgradeHandler( @@ -23,11 +31,10 @@ func CreateUpgradeHandler( ctx.Logger().Info("Starting upgrade v26...") err := icqoracleKeeper.SetParams(ctx, icqoracletypes.Params{ - OsmosisChainId: "osmosis-1", - OsmosisConnectionId: "connection-2", - UpdateIntervalSec: 5 * 60, // 5 min - PriceExpirationTimeoutSec: 10 * 60, // 10 min - IcqTimeoutSec: 2 * 60, // 2 min + OsmosisChainId: OsmosisChainId, + OsmosisConnectionId: OsmosisConnectionId, + UpdateIntervalSec: ICQOracleUpdateIntervalSec, + PriceExpirationTimeoutSec: ICQOraclePriceExpirationTimeoutSec, }) if err != nil { panic(fmt.Errorf("unable to set icqoracle params: %w", err)) diff --git a/app/upgrades/v26/upgrades_test.go b/app/upgrades/v26/upgrades_test.go index dd71203d1b..aa9ee632f0 100644 --- a/app/upgrades/v26/upgrades_test.go +++ b/app/upgrades/v26/upgrades_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/Stride-Labs/stride/v25/app/apptesting" + v26 "github.com/Stride-Labs/stride/v25/app/upgrades/v26" ) type UpgradeTestSuite struct { @@ -21,4 +22,14 @@ func TestKeeperTestSuite(t *testing.T) { } func (s *UpgradeTestSuite) TestUpgrade() { + upgradeHeight := int64(4) + + s.ConfirmUpgradeSucceededs(v26.UpgradeName, upgradeHeight) + + params, err := s.App.ICQOracleKeeper.GetParams(s.Ctx) + s.Require().NoError(err, "No error expected when getting params") + s.Require().Equal(v26.OsmosisChainId, params.OsmosisChainId, "Osmosis chain ID") + s.Require().Equal(v26.OsmosisConnectionId, params.OsmosisConnectionId, "Osmosis connection ID") + s.Require().Equal(v26.ICQOracleUpdateIntervalSec, params.UpdateIntervalSec, "Update interval") + s.Require().Equal(v26.ICQOraclePriceExpirationTimeoutSec, params.PriceExpirationTimeoutSec, "Timeout") } From 845c7db7cbe456791f85fe377271e4a479bf87d4 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Feb 2025 11:12:59 -0600 Subject: [PATCH 110/115] updated buyback and burn ICQ logic (#1344) Co-authored-by: Assaf Morami --- proto/stride/icqoracle/icqoracle.proto | 17 +-- proto/stride/icqoracle/query.proto | 10 +- x/auction/keeper/msg_server_test.go | 8 +- x/icqoracle/keeper/abci.go | 31 ++-- x/icqoracle/keeper/abci_test.go | 111 ++++++-------- x/icqoracle/keeper/icq.go | 24 ++- x/icqoracle/keeper/icq_test.go | 25 ++-- x/icqoracle/keeper/keeper.go | 27 +++- x/icqoracle/keeper/msg_server.go | 2 +- x/icqoracle/keeper/msg_server_test.go | 4 +- x/icqoracle/keeper/params_test.go | 3 +- x/icqoracle/keeper/query.go | 2 +- x/icqoracle/keeper/query_test.go | 143 +++++++++--------- x/icqoracle/types/genesis.go | 2 +- x/icqoracle/types/icqoracle.pb.go | 193 ++++++++++++++----------- x/icqoracle/types/query.pb.go | 186 +++++++++++++++--------- x/interchainquery/keeper/events.go | 24 +++ x/interchainquery/keeper/msg_server.go | 17 +-- x/interchainquery/types/error.go | 1 + x/interchainquery/types/events.go | 2 + 20 files changed, 450 insertions(+), 382 deletions(-) create mode 100644 x/interchainquery/keeper/events.go diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index ab5a2eec52..628e729c82 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -29,12 +29,16 @@ message TokenPrice { (gogoproto.nullable) = false ]; - // Last update timestamp - google.protobuf.Timestamp updated_at = 9 + // Last time a query request was submitted + google.protobuf.Timestamp last_request_time = 9 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + + // Last time a query response was received + google.protobuf.Timestamp last_response_time = 10 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // Whether there is a spot price query currently in progress - bool query_in_progress = 10; + bool query_in_progress = 11; } // OracleParams stores global oracle parameters @@ -52,6 +56,7 @@ message Params { ]; // Time between price updates + // Also used to timeout icq requests uint64 update_interval_sec = 3 [ (gogoproto.moretags) = "yaml:\"update_interval_sec\"", (gogoproto.jsontag) = "update_interval_sec" @@ -62,10 +67,4 @@ message Params { (gogoproto.moretags) = "yaml:\"price_expiration_timeout_sec\"", (gogoproto.jsontag) = "price_expiration_timeout_sec" ]; - - // ICQ timeout - uint64 icq_timeout_sec = 5 [ - (gogoproto.moretags) = "yaml:\"icq_timeout_sec\"", - (gogoproto.jsontag) = "icq_timeout_sec" - ]; } diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index 6b352e1ea4..441ef9f08a 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -111,10 +111,14 @@ message TokenPriceResponse { (gogoproto.nullable) = false ]; - // Last update timestamp - google.protobuf.Timestamp updated_at = 11 + // Last time a query request was submitted + google.protobuf.Timestamp last_request_time = 11 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + + // Last time a query response was received + google.protobuf.Timestamp last_response_time = 12 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // Whether there is a spot price query currently in progress - bool query_in_progress = 12; + bool query_in_progress = 13; } \ No newline at end of file diff --git a/x/auction/keeper/msg_server_test.go b/x/auction/keeper/msg_server_test.go index 9c10c5b202..37bfd89c7b 100644 --- a/x/auction/keeper/msg_server_test.go +++ b/x/auction/keeper/msg_server_test.go @@ -106,7 +106,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidHappyPath() { QuoteDenom: auction.PaymentDenom, OsmosisPoolId: "1", SpotPrice: sdkmath.LegacyNewDec(1), - UpdatedAt: s.Ctx.BlockTime(), + LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) @@ -296,7 +296,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { QuoteDenom: "uusdc", OsmosisPoolId: "1", SpotPrice: sdkmath.LegacyNewDec(1), - UpdatedAt: s.Ctx.BlockTime(), + LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) @@ -341,7 +341,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { QuoteDenom: auction.PaymentDenom, OsmosisPoolId: "1", SpotPrice: sdkmath.LegacyNewDec(1), - UpdatedAt: s.Ctx.BlockTime(), + LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) @@ -392,7 +392,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { QuoteDenom: auction.PaymentDenom, OsmosisPoolId: "1", SpotPrice: sdkmath.LegacyNewDec(1), - UpdatedAt: s.Ctx.BlockTime(), + LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index d21d0c3bb3..fa2b20dcfa 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -7,40 +7,31 @@ import ( ) func (k Keeper) BeginBlocker(ctx sdk.Context) { - // Get all token prices params, err := k.GetParams(ctx) if err != nil { - // Can't really do anything but log - // A panic would halt the chain ctx.Logger().Error("failed to get icqoracle params: %w", err) return } currentTime := ctx.BlockTime() - // Iterate through each token price - tokenPrices := k.GetAllTokenPrices(ctx) - for _, tokenPrice := range tokenPrices { + for _, tokenPrice := range k.GetAllTokenPrices(ctx) { // Get last update time for this token - lastUpdate := tokenPrice.UpdatedAt + lastUpdate := tokenPrice.LastRequestTime + isNewToken := lastUpdate.IsZero() + updateIntervalPassed := currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) - // Skip if there's already a query in progress - if tokenPrice.QueryInProgress { - continue - } - - // If never updated or update interval has passed - if lastUpdate.IsZero() || currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) { - // Update price for this specific token - err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice) - if err != nil { - // Can't really do anything but log + // If never updated or update interval has passed, submit a new query for the price + // If a query was already in progress, it will be replaced with this new one that will + // will have the same query ID + if isNewToken || updateIntervalPassed { + if err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice); err != nil { ctx.Logger().Error( - "failed to submit Osmosis CL pool ICQ error='%w' baseToken='%s' quoteToken='%s' poolId='%s'", - err, + "failed to submit Osmosis CL pool ICQ baseToken='%s' quoteToken='%s' poolId='%s': %w", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, + err, ) continue } diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go index 94e8ab509c..cec75610f6 100644 --- a/x/icqoracle/keeper/abci_test.go +++ b/x/icqoracle/keeper/abci_test.go @@ -41,7 +41,6 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { params := types.Params{ UpdateIntervalSec: 60, // 1 minute interval - IcqTimeoutSec: 30, } now := time.Now().UTC() @@ -56,63 +55,30 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { { name: "never updated token price", tokenPrice: types.TokenPrice{ - BaseDenom: "uatom", - QuoteDenom: "uusdc", - OsmosisPoolId: "1", - UpdatedAt: time.Time{}, // Zero time + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + LastRequestTime: time.Time{}, // Zero time }, expectedICQSubmit: true, }, { name: "stale token price", tokenPrice: types.TokenPrice{ - BaseDenom: "uosmo", - QuoteDenom: "uusdc", - OsmosisPoolId: "2", - UpdatedAt: staleTime, + BaseDenom: "uosmo", + QuoteDenom: "uusdc", + OsmosisPoolId: "2", + LastRequestTime: staleTime, }, expectedICQSubmit: true, }, { name: "fresh token price", tokenPrice: types.TokenPrice{ - BaseDenom: "ustrd", - QuoteDenom: "uusdc", - OsmosisPoolId: "3", - UpdatedAt: freshTime, - }, - expectedICQSubmit: false, - }, - { - name: "query in progress stale token price", - tokenPrice: types.TokenPrice{ - BaseDenom: "ujuno", - QuoteDenom: "uusdc", - OsmosisPoolId: "4", - UpdatedAt: staleTime, - QueryInProgress: true, - }, - expectedICQSubmit: false, - }, - { - name: "query in progress fresh token price", - tokenPrice: types.TokenPrice{ - BaseDenom: "udydx", - QuoteDenom: "uusdc", - OsmosisPoolId: "5", - UpdatedAt: freshTime, - QueryInProgress: true, - }, - expectedICQSubmit: false, - }, - { - name: "query in progress never updated token price", - tokenPrice: types.TokenPrice{ - BaseDenom: "utia", + BaseDenom: "ustrd", QuoteDenom: "uusdc", - OsmosisPoolId: "6", - UpdatedAt: time.Time{}, // Zero time - QueryInProgress: true, + OsmosisPoolId: "3", + LastRequestTime: freshTime, }, expectedICQSubmit: false, }, @@ -171,17 +137,16 @@ func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { // Set params params := types.Params{ UpdateIntervalSec: 60, - IcqTimeoutSec: 30, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) // Create token price that needs updating tokenPrice := types.TokenPrice{ - BaseDenom: "uatom", - QuoteDenom: "uusdc", - OsmosisPoolId: "1", - UpdatedAt: time.Time{}, // Zero time to trigger update + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + LastRequestTime: time.Time{}, // Zero time to trigger update } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err) @@ -221,7 +186,6 @@ func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { // Set params params := types.Params{ UpdateIntervalSec: 60, - IcqTimeoutSec: 30, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -232,23 +196,32 @@ func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { // Create multiple token prices tokenPrices := []types.TokenPrice{ { - BaseDenom: "uatom", - QuoteDenom: "uusdc", - OsmosisPoolId: "1", - UpdatedAt: staleTime, + BaseDenom: "uatom", + QuoteDenom: "uusdc", + OsmosisPoolId: "1", + LastRequestTime: staleTime, + QueryInProgress: false, }, { - BaseDenom: "uosmo", - QuoteDenom: "uusdc", - OsmosisPoolId: "2", - UpdatedAt: staleTime, + BaseDenom: "uosmo", + QuoteDenom: "uusdc", + OsmosisPoolId: "2", + LastRequestTime: staleTime, + QueryInProgress: false, }, { BaseDenom: "ustrd", QuoteDenom: "uusdc", OsmosisPoolId: "3", - UpdatedAt: staleTime, - QueryInProgress: true, // Should skip this one + LastRequestTime: s.Ctx.BlockTime(), // Should skip this one + QueryInProgress: true, + }, + { + BaseDenom: "ustrd", + QuoteDenom: "uusdc", + OsmosisPoolId: "4", + LastRequestTime: s.Ctx.BlockTime(), // Should skip this one + QueryInProgress: false, }, } @@ -269,14 +242,14 @@ func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { "expected 2 ICQ queries to be submitted (skipping the one in progress)") // Verify query in progress flags - for _, tp := range tokenPrices { + for _, tp := range tokenPrices[:2] { + updatedPrice := s.MustGetTokenPrice(tp.BaseDenom, tp.QuoteDenom, tp.OsmosisPoolId) + s.Require().True(updatedPrice.QueryInProgress, + "query in progress should be set to true for tokens that are updating") + } + for _, tp := range tokenPrices[2:] { updatedPrice := s.MustGetTokenPrice(tp.BaseDenom, tp.QuoteDenom, tp.OsmosisPoolId) - if tp.QueryInProgress { - s.Require().True(updatedPrice.QueryInProgress, - "query in progress should remain true for token that was already updating") - } else { - s.Require().True(updatedPrice.QueryInProgress, - "query in progress should be true for tokens that needed updates") - } + s.Require().Equal(tp.QueryInProgress, updatedPrice.QueryInProgress, + "query in progress should not change for tokens that are not updating") } } diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index b7c09fa587..575616d279 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -63,7 +63,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( params, err := k.GetParams(ctx) if err != nil { - return errorsmod.Wrapf(err, "Error getting module params") + return errorsmod.Wrap(err, "Error getting module params") } osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) @@ -84,20 +84,22 @@ func (k Keeper) SubmitOsmosisClPoolICQ( CallbackModule: types.ModuleName, CallbackId: ICQCallbackID_OsmosisClPool, CallbackData: tokenPriceBz, - TimeoutDuration: time.Duration(params.IcqTimeoutSec) * time.Second, + TimeoutDuration: time.Duration(params.UpdateIntervalSec) * time.Second, TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, } - if err := k.IcqKeeper.SubmitICQRequest(ctx, query, true); err != nil { - return errorsmod.Wrapf(err, "Error submitting OsmosisClPool ICQ") + + if err := k.IcqKeeper.SubmitICQRequest(ctx, query, false); err != nil { + return errorsmod.Wrap(err, "Error submitting OsmosisClPool ICQ") } - if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, true); err != nil { - return errorsmod.Wrapf(err, "Error updating queryInProgress=true") + if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId); err != nil { + return errorsmod.Wrap(err, "Error updating token price query to in progress") } return nil } +// Callback from Osmosis spot price query func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error { var tokenPrice types.TokenPrice if err := k.cdc.Unmarshal(query.CallbackData, &tokenPrice); err != nil { @@ -118,18 +120,14 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype return nil } - // Unmarshal the query response args to determine the balance + // Unmarshal the query response args to determine the prices newSpotPrice, err := UnmarshalSpotPriceFromOsmosisClPool(tokenPrice, args) if err != nil { return errorsmod.Wrap(err, "Error determining spot price from query response") } - tokenPrice.SpotPrice = newSpotPrice - tokenPrice.QueryInProgress = false - tokenPrice.UpdatedAt = ctx.BlockTime() - - if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { - return errorsmod.Wrap(err, "Error updating spot price from query response") + if err := k.SetTokenPriceQueryComplete(ctx, tokenPrice, newSpotPrice); err != nil { + return errorsmod.Wrapf(err, "Unable to mark token price query as complete") } return nil diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index 55de0ed147..1389455fd2 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -39,7 +39,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQUnknownPrice() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -74,7 +74,7 @@ func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err = s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -95,7 +95,8 @@ func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { tokenPriceAfter, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) s.Require().NoError(err) - s.Require().True(tokenPriceAfter.QueryInProgress) + s.Require().True(tokenPriceAfter.QueryInProgress, "query in progress") + s.Require().Equal(tokenPriceAfter.LastRequestTime, s.Ctx.BlockTime(), "query request time") } func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { @@ -112,7 +113,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -130,7 +131,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -156,7 +157,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -178,7 +179,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { QuoteDenom: "uusdc", OsmosisPoolId: "1", }, - expectedError: "Error updating queryInProgress=true", + expectedError: "Error updating token price query to in progress", }, { name: "successful submission", @@ -186,7 +187,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -271,7 +272,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", - IcqTimeoutSec: 60, + UpdateIntervalSec: 60, } err = s.App.ICQOracleKeeper.SetParams(s.Ctx, params) s.Require().NoError(err) @@ -302,7 +303,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { s.Require().Equal(tokenPrice.OsmosisPoolId, decodedTokenPrice.OsmosisPoolId) // Verify timeout settings - expectedTimeout := time.Duration(params.IcqTimeoutSec) * time.Second + expectedTimeout := time.Duration(params.UpdateIntervalSec) * time.Second s.Require().Equal(expectedTimeout, capturedQuery.TimeoutDuration) s.Require().Equal(icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE, capturedQuery.TimeoutPolicy) } @@ -429,7 +430,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { // Verify updated fields s.Require().False(tokenPrice.QueryInProgress) - s.Require().Equal(s.Ctx.BlockTime().UnixNano(), tokenPrice.UpdatedAt.UnixNano()) + s.Require().Equal(s.Ctx.BlockTime().UnixNano(), tokenPrice.LastResponseTime.UnixNano()) s.Require().InDelta(1.5, tokenPrice.SpotPrice.MustFloat64(), 0.01) }, }, @@ -465,7 +466,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { // Verify updated fields s.Require().False(tokenPrice.QueryInProgress) - s.Require().Equal(s.Ctx.BlockTime().UnixNano(), tokenPrice.UpdatedAt.UnixNano()) + s.Require().Equal(s.Ctx.BlockTime().UnixNano(), tokenPrice.LastResponseTime.UnixNano()) s.Require().InDelta(1/1.5, tokenPrice.SpotPrice.MustFloat64(), 0.01) // inversed price }, }, diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 6b79185fa1..efc9178252 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" @@ -60,13 +61,16 @@ func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom s store.Delete(key) } -func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string, queryInProgress bool) error { +// Updates the token price when a query is requested +func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) error { tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom, osmosisPoolId) if err != nil { return err } - tokenPrice.QueryInProgress = queryInProgress + tokenPrice.QueryInProgress = true + tokenPrice.LastRequestTime = ctx.BlockTime() + err = k.SetTokenPrice(ctx, tokenPrice) if err != nil { return err @@ -75,6 +79,19 @@ func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, return nil } +// Updates the token price when a query response is received +func (k Keeper) SetTokenPriceQueryComplete(ctx sdk.Context, tokenPrice types.TokenPrice, newSpotPrice math.LegacyDec) error { + tokenPrice.SpotPrice = newSpotPrice + tokenPrice.QueryInProgress = false + tokenPrice.LastResponseTime = ctx.BlockTime() + + if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { + return errorsmod.Wrap(err, "Error updating spot price from query response") + } + + return nil +} + // GetTokenPrice retrieves price data for a token func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) (types.TokenPrice, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) @@ -159,7 +176,7 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu // Check if baseDenom already has a price for quoteDenom foundAlreadyHasStalePrice := false if price, ok := baseTokenPrices[quoteDenom]; ok { - if ctx.BlockTime().Unix()-price.UpdatedAt.Unix() <= priceExpirationTimeoutSec { + if ctx.BlockTime().Unix()-price.LastRequestTime.Unix() <= priceExpirationTimeoutSec { return price.SpotPrice, nil } else { foundAlreadyHasStalePrice = true @@ -191,11 +208,11 @@ func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, qu foundCommonQuoteToken = true // Check that both prices are not stale - if ctx.BlockTime().Unix()-baseTokenPrice.UpdatedAt.Unix() > priceExpirationTimeoutSec { + if ctx.BlockTime().Unix()-baseTokenPrice.LastRequestTime.Unix() > priceExpirationTimeoutSec { foundBaseTokenStalePrice = true continue } - if ctx.BlockTime().Unix()-quoteTokenPrice.UpdatedAt.Unix() > priceExpirationTimeoutSec { + if ctx.BlockTime().Unix()-quoteTokenPrice.LastRequestTime.Unix() > priceExpirationTimeoutSec { foundQuoteTokenStalePrice = true continue } diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index 628ce86c7d..040bd36c0b 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -37,7 +37,7 @@ func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.Ms OsmosisPoolId: msg.OsmosisPoolId, OsmosisBaseDenom: msg.OsmosisBaseDenom, OsmosisQuoteDenom: msg.OsmosisQuoteDenom, - UpdatedAt: time.Time{}, + LastRequestTime: time.Time{}, SpotPrice: sdkmath.LegacyZeroDec(), QueryInProgress: false, } diff --git a/x/icqoracle/keeper/msg_server_test.go b/x/icqoracle/keeper/msg_server_test.go index e7ff4ddbf8..5745856005 100644 --- a/x/icqoracle/keeper/msg_server_test.go +++ b/x/icqoracle/keeper/msg_server_test.go @@ -31,7 +31,7 @@ func (s *KeeperTestSuite) TestRegisterTokenPriceQuery() { s.Require().Equal(msg.OsmosisQuoteDenom, tokenPrice.OsmosisQuoteDenom, "osmosis quote denom") s.Require().Equal(sdkmath.LegacyZeroDec(), tokenPrice.SpotPrice, "spot price") s.Require().Equal(false, tokenPrice.QueryInProgress, "query in progress") - s.Require().Equal(time.Time{}, tokenPrice.UpdatedAt, "updated at") + s.Require().Equal(time.Time{}, tokenPrice.LastRequestTime, "updated at") // Attempt to register it again, it should fail _, err = s.GetMsgServer().RegisterTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) @@ -47,7 +47,7 @@ func (s *KeeperTestSuite) TestRemoveTokenPriceQuery() { OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "uusdc", SpotPrice: sdkmath.LegacyNewDec(1), - UpdatedAt: time.Now().UTC(), + LastRequestTime: time.Now().UTC(), QueryInProgress: false, } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) diff --git a/x/icqoracle/keeper/params_test.go b/x/icqoracle/keeper/params_test.go index ae7a7d3a49..7367394937 100644 --- a/x/icqoracle/keeper/params_test.go +++ b/x/icqoracle/keeper/params_test.go @@ -7,8 +7,7 @@ func (s *KeeperTestSuite) TestParams() { OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-2", UpdateIntervalSec: 5 * 60, // 5 min - PriceExpirationTimeoutSec: 10 * 60, // 10 min - IcqTimeoutSec: 2 * 60, // 2 min + PriceExpirationTimeoutSec: 15 * 60, // 15 min } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) s.Require().NoError(err, "should not error on set params") diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index 6da1cd7a67..f11c4ec182 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -121,7 +121,7 @@ func (k Keeper) TokenPriceToTokenPriceResponse(ctx sdk.Context, tokenPrices ...t OsmosisQuoteDenom: tokenPrice.OsmosisQuoteDenom, OsmosisPoolId: tokenPrice.OsmosisPoolId, SpotPrice: tokenPrice.SpotPrice, - UpdatedAt: tokenPrice.UpdatedAt, + LastRequestTime: tokenPrice.LastRequestTime, QueryInProgress: tokenPrice.QueryInProgress, } } diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index 7851879239..a176d23ca8 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -88,8 +88,7 @@ func (s *KeeperTestSuite) TestQueryParams() { OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-2", UpdateIntervalSec: 5 * 60, // 5 min - PriceExpirationTimeoutSec: 10 * 60, // 10 min - IcqTimeoutSec: 2 * 60, // 2 min + PriceExpirationTimeoutSec: 15 * 60, // 15 min } err := s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) s.Require().NoError(err, "no error expected when setting params") @@ -128,11 +127,11 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { expectedPrice := sdkmath.LegacyNewDec(1000000) tokenPrice := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, - OsmosisPoolId: "1", - SpotPrice: expectedPrice, - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: "1", + SpotPrice: expectedPrice, + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice) @@ -174,22 +173,22 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { // Set uatom price tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom1, - QuoteDenom: quoteDenom, - OsmosisPoolId: "1", - SpotPrice: expectedPrice1, - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom1, + QuoteDenom: quoteDenom, + OsmosisPoolId: "1", + SpotPrice: expectedPrice1, + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice1) // Set uosmo price tokenPrice2 := types.TokenPrice{ - BaseDenom: baseDenom2, - QuoteDenom: quoteDenom, - OsmosisPoolId: "2", - SpotPrice: expectedPrice2, - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom2, + QuoteDenom: quoteDenom, + OsmosisPoolId: "2", + SpotPrice: expectedPrice2, + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice2) @@ -218,11 +217,11 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { expectedPrice := sdkmath.LegacyNewDec(1000000) tokenPrice := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: quoteDenom, - OsmosisPoolId: "1", - SpotPrice: expectedPrice, - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom, + QuoteDenom: quoteDenom, + OsmosisPoolId: "1", + SpotPrice: expectedPrice, + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err) @@ -248,22 +247,22 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { // Set base token price tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: intermediateQuote, - OsmosisPoolId: "1", - SpotPrice: sdkmath.LegacyNewDec(1000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + LastRequestTime: s.Ctx.BlockTime(), } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err) // Set quote token price with zero value tokenPrice2 := types.TokenPrice{ - BaseDenom: quoteDenom, - QuoteDenom: intermediateQuote, - OsmosisPoolId: "2", - SpotPrice: sdkmath.LegacyZeroDec(), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: quoteDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyZeroDec(), + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) s.Require().NoError(err) @@ -285,22 +284,22 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { // Set base token price with one quote denom tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: "quote1", - OsmosisPoolId: "1", - SpotPrice: sdkmath.LegacyNewDec(1000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom, + QuoteDenom: "quote1", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + LastRequestTime: s.Ctx.BlockTime(), } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err) // Set quote token price with different quote denom tokenPrice2 := types.TokenPrice{ - BaseDenom: quoteDenom, - QuoteDenom: "quote2", - OsmosisPoolId: "2", - SpotPrice: sdkmath.LegacyNewDec(2000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: quoteDenom, + QuoteDenom: "quote2", + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) s.Require().NoError(err) @@ -322,11 +321,11 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomParamsError() { // Set base token price with one quote denom tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: "quote1", - OsmosisPoolId: "1", - SpotPrice: sdkmath.LegacyNewDec(1000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom, + QuoteDenom: "quote1", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + LastRequestTime: s.Ctx.BlockTime(), } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err) @@ -354,11 +353,11 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoBaseDenom() { func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoQuoteDenom() { // Set base token price with one quote denom tokenPrice1 := types.TokenPrice{ - BaseDenom: "banana", - QuoteDenom: "quote1", - OsmosisPoolId: "1", - SpotPrice: sdkmath.LegacyNewDec(1000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: "banana", + QuoteDenom: "quote1", + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + LastRequestTime: s.Ctx.BlockTime(), } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err) @@ -387,22 +386,22 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { // Set base token price (will become stale) tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: intermediateQuote, - OsmosisPoolId: "1", - SpotPrice: sdkmath.LegacyNewDec(1000000), - UpdatedAt: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale + BaseDenom: baseDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + LastRequestTime: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err) // Set quote token price (fresh) tokenPrice2 := types.TokenPrice{ - BaseDenom: quoteDenom, - QuoteDenom: intermediateQuote, - OsmosisPoolId: "2", - SpotPrice: sdkmath.LegacyNewDec(2000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: quoteDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) s.Require().NoError(err) @@ -432,22 +431,22 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { // Set base token price (fresh) tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: intermediateQuote, - OsmosisPoolId: "1", - SpotPrice: sdkmath.LegacyNewDec(1000000), - UpdatedAt: s.Ctx.BlockTime(), + BaseDenom: baseDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "1", + SpotPrice: sdkmath.LegacyNewDec(1000000), + LastRequestTime: s.Ctx.BlockTime(), } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) s.Require().NoError(err) // Set quote token price (will be stale) tokenPrice2 := types.TokenPrice{ - BaseDenom: quoteDenom, - QuoteDenom: intermediateQuote, - OsmosisPoolId: "2", - SpotPrice: sdkmath.LegacyNewDec(2000000), - UpdatedAt: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale + BaseDenom: quoteDenom, + QuoteDenom: intermediateQuote, + OsmosisPoolId: "2", + SpotPrice: sdkmath.LegacyNewDec(2000000), + LastRequestTime: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale } err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) s.Require().NoError(err) diff --git a/x/icqoracle/types/genesis.go b/x/icqoracle/types/genesis.go index 8f941ca270..2a93b3e5a2 100644 --- a/x/icqoracle/types/genesis.go +++ b/x/icqoracle/types/genesis.go @@ -11,7 +11,7 @@ func DefaultGenesis() *GenesisState { // Performs basic genesis state validation by iterating through all token prices and validating // using ValidateTokenPriceQueryParams(). -// We ignore the SpotPrice, UpdatedAt & QueryInProgress fields since they are reset in InitGenesis(). +// We ignore the SpotPrice, LastRequestTime & QueryInProgress fields since they are reset in InitGenesis(). func (gs GenesisState) Validate() error { for i, tokenPrice := range gs.TokenPrices { err := ValidateTokenPriceQueryParams( diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 33df8ff06c..1d7743da22 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -46,10 +46,12 @@ type TokenPrice struct { OsmosisPoolId string `protobuf:"bytes,7,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` // Spot price of base_denom denominated in quote_denom SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` - // Last update timestamp - UpdatedAt time.Time `protobuf:"bytes,9,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + // Last time a query request was submitted + LastRequestTime time.Time `protobuf:"bytes,9,opt,name=last_request_time,json=lastRequestTime,proto3,stdtime" json:"last_request_time"` + // Last time a query response was received + LastResponseTime time.Time `protobuf:"bytes,10,opt,name=last_response_time,json=lastResponseTime,proto3,stdtime" json:"last_response_time"` // Whether there is a spot price query currently in progress - QueryInProgress bool `protobuf:"varint,10,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` + QueryInProgress bool `protobuf:"varint,11,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` } func (m *TokenPrice) Reset() { *m = TokenPrice{} } @@ -134,9 +136,16 @@ func (m *TokenPrice) GetOsmosisPoolId() string { return "" } -func (m *TokenPrice) GetUpdatedAt() time.Time { +func (m *TokenPrice) GetLastRequestTime() time.Time { if m != nil { - return m.UpdatedAt + return m.LastRequestTime + } + return time.Time{} +} + +func (m *TokenPrice) GetLastResponseTime() time.Time { + if m != nil { + return m.LastResponseTime } return time.Time{} } @@ -155,11 +164,10 @@ type Params struct { // Osmosis IBC connection identifier OsmosisConnectionId string `protobuf:"bytes,2,opt,name=osmosis_connection_id,json=osmosisConnectionId,proto3" json:"osmosis_connection_id" yaml:"osmosis_connection_id"` // Time between price updates + // Also used to timeout icq requests UpdateIntervalSec uint64 `protobuf:"varint,3,opt,name=update_interval_sec,json=updateIntervalSec,proto3" json:"update_interval_sec" yaml:"update_interval_sec"` // Max time before price is considered stale/expired PriceExpirationTimeoutSec uint64 `protobuf:"varint,4,opt,name=price_expiration_timeout_sec,json=priceExpirationTimeoutSec,proto3" json:"price_expiration_timeout_sec" yaml:"price_expiration_timeout_sec"` - // ICQ timeout - IcqTimeoutSec uint64 `protobuf:"varint,5,opt,name=icq_timeout_sec,json=icqTimeoutSec,proto3" json:"icq_timeout_sec" yaml:"icq_timeout_sec"` } func (m *Params) Reset() { *m = Params{} } @@ -223,13 +231,6 @@ func (m *Params) GetPriceExpirationTimeoutSec() uint64 { return 0 } -func (m *Params) GetIcqTimeoutSec() uint64 { - if m != nil { - return m.IcqTimeoutSec - } - return 0 -} - func init() { proto.RegisterType((*TokenPrice)(nil), "stride.icqoracle.TokenPrice") proto.RegisterType((*Params)(nil), "stride.icqoracle.Params") @@ -238,48 +239,48 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 654 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x4d, 0x6f, 0xd3, 0x30, - 0x18, 0xc7, 0x1b, 0xd6, 0x8d, 0xd5, 0xd3, 0xd8, 0x9a, 0x0d, 0x28, 0x65, 0xd4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0, 0x66, 0x29, 0xe1, 0x34, 0xa0, 0x2a, 0x03, 0xd4, 0x69, 0xe6, 0x22, 0xe2, - 0x25, 0x50, 0x19, 0xf7, 0x19, 0xa7, 0xdc, 0x2e, 0x75, 0xba, 0x28, 0x3b, 0x59, 0xcf, 0x88, 0x59, - 0x34, 0xac, 0x83, 0x8d, 0xdc, 0x5d, 0x6e, 0x7c, 0x49, 0xda, 0xeb, 0x19, 0xfa, 0x38, 0xed, 0xff, - 0x39, 0x58, 0xcb, 0xfd, 0x21, 0x63, 0x9e, 0x4d, 0x9d, 0xc6, 0x7d, 0xe9, 0x5d, 0xcd, 0xe4, 0x1e, - 0x63, 0x5e, 0xd7, 0x51, 0x4d, 0x00, 0x78, 0xc8, 0x84, 0x1d, 0x26, 0x53, 0x6b, 0x2c, 0x27, 0x16, - 0x73, 0xfb, 0x2a, 0x86, 0x95, 0x9f, 0x31, 0x7c, 0x8a, 0xa5, 0x97, 0x3b, 0x67, 0x3a, 0x65, 0x86, - 0x8f, 0xc4, 0xa9, 0x7e, 0x44, 0x5c, 0x84, 0x47, 0x87, 0x04, 0x5b, 0xb5, 0x24, 0x2c, 0x9d, 0xf5, - 0x01, 0x00, 0xc3, 0xd0, 0x41, 0x82, 0x38, 0x36, 0x12, 0x8d, 0x5a, 0x5b, 0xe9, 0xac, 0xec, 0x36, - 0xf5, 0x74, 0x61, 0x7a, 0xbe, 0x30, 0xfd, 0x24, 0x5f, 0x98, 0xb9, 0x9c, 0xe4, 0xbf, 0xfc, 0x05, - 0x15, 0xab, 0x96, 0xc5, 0xbd, 0x15, 0xea, 0x0b, 0x50, 0x1f, 0x0c, 0x49, 0x34, 0xb2, 0x69, 0x60, - 0x87, 0x11, 0x73, 0x23, 0xc2, 0x79, 0x03, 0xb4, 0x95, 0xce, 0xb2, 0xb5, 0x26, 0x41, 0x37, 0xe8, - 0x65, 0xb2, 0xf6, 0xbd, 0x0a, 0x96, 0x7a, 0x28, 0x42, 0x3e, 0x57, 0x3f, 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 0xf3, 0xc3, 0xd5, 0x4d, 0x4b, 0xb9, 0xbe, 0x69, 0x29, 0xbf, 0x6f, 0x5a, 0xca, - 0xe5, 0x6d, 0xab, 0x72, 0x7d, 0xdb, 0xaa, 0xfc, 0xb8, 0x6d, 0x55, 0xbe, 0xec, 0xb9, 0x54, 0x9c, - 0x0e, 0xfb, 0x3a, 0x66, 0xbe, 0x71, 0x2c, 0xdf, 0x9d, 0x9d, 0x23, 0xd4, 0xe7, 0x46, 0xf6, 0x4a, - 0x9d, 0xef, 0xee, 0x1b, 0x17, 0xa5, 0xb7, 0x4a, 0x8c, 0x42, 0xc2, 0xfb, 0x4b, 0xf2, 0x06, 0xef, - 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xac, 0xd2, 0x75, 0xcc, 0x04, 0x00, 0x00, + // 652 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0x8f, 0x69, 0x28, 0xcd, 0x55, 0xd0, 0xc6, 0x2d, 0x22, 0x84, 0x12, 0x47, 0xae, 0x84, 0x22, + 0x04, 0x36, 0x6a, 0xd5, 0x01, 0x46, 0xb7, 0x08, 0x45, 0x2a, 0x52, 0x70, 0xbb, 0xc0, 0x62, 0x5d, + 0xce, 0x87, 0x7b, 0xaa, 0xed, 0x73, 0x7c, 0xe7, 0xaa, 0xf9, 0x06, 0x8c, 0xfd, 0x50, 0x0c, 0x15, + 0x53, 0x47, 0xc4, 0x60, 0x50, 0xbb, 0x65, 0xcc, 0x27, 0x40, 0x77, 0x67, 0x3b, 0x51, 0x89, 0x2a, + 0xb1, 0xd9, 0xbf, 0x7f, 0xef, 0xe9, 0xde, 0xd3, 0x03, 0x5d, 0xc6, 0x53, 0xe2, 0x63, 0x9b, 0xa0, + 0x11, 0x4d, 0x21, 0x0a, 0xe7, 0xbe, 0xac, 0x24, 0xa5, 0x9c, 0xea, 0xeb, 0x4a, 0x61, 0x55, 0x78, + 0x7b, 0x33, 0xa0, 0x01, 0x95, 0xa4, 0x2d, 0xbe, 0x94, 0xae, 0x6d, 0x04, 0x94, 0x06, 0x21, 0xb6, + 0xe5, 0xdf, 0x30, 0xfb, 0x6a, 0x73, 0x12, 0x61, 0xc6, 0x61, 0x94, 0x28, 0x81, 0xf9, 0xa3, 0x0e, + 0xc0, 0x31, 0x3d, 0xc5, 0xf1, 0x20, 0x25, 0x08, 0xeb, 0xcf, 0x01, 0x18, 0x42, 0x86, 0x3d, 0x1f, + 0xc7, 0x34, 0x6a, 0x69, 0x5d, 0xad, 0xd7, 0x70, 0x1b, 0x02, 0x39, 0x10, 0x80, 0x6e, 0x80, 0xd5, + 0x51, 0x46, 0x79, 0xc9, 0xdf, 0x93, 0x3c, 0x90, 0x90, 0x12, 0x58, 0x60, 0x63, 0xe6, 0xf7, 0x7c, + 0x8c, 0x48, 0x04, 0x43, 0xd6, 0x5a, 0xea, 0x6a, 0xbd, 0x25, 0xb7, 0x59, 0x05, 0x1d, 0x14, 0x84, + 0xfe, 0x06, 0x6c, 0xce, 0x05, 0xce, 0x0c, 0x75, 0x69, 0xd0, 0x67, 0xc9, 0x95, 0xe3, 0x15, 0xd0, + 0x29, 0x8b, 0x28, 0x23, 0xcc, 0x9b, 0xeb, 0xf4, 0xbe, 0xec, 0x64, 0xbd, 0x60, 0x9c, 0xaa, 0x61, + 0x0b, 0x6c, 0x94, 0xea, 0xf9, 0xc6, 0x97, 0xa5, 0xbc, 0x59, 0x50, 0x9f, 0x66, 0xfd, 0xbf, 0x00, + 0x6b, 0xa5, 0x3e, 0xa1, 0x34, 0xf4, 0x88, 0xdf, 0x7a, 0x20, 0xb5, 0x0f, 0x0b, 0x78, 0x40, 0x69, + 0xd8, 0xf7, 0x75, 0x07, 0x00, 0x96, 0x50, 0xee, 0x25, 0xe2, 0xd5, 0x5a, 0x2b, 0x42, 0xe2, 0x6c, + 0x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rice) Marshal() (dAtA []byte, err error) { @@ -310,15 +311,23 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x50 + dAtA[i] = 0x58 } - n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastResponseTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastResponseTime):]) if err1 != nil { return 0, err1 } i -= n1 i = encodeVarintIcqoracle(dAtA, i, uint64(n1)) i-- + dAtA[i] = 0x52 + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastRequestTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRequestTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintIcqoracle(dAtA, i, uint64(n2)) + i-- dAtA[i] = 0x4a { size := m.SpotPrice.Size() @@ -398,11 +407,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.IcqTimeoutSec != 0 { - i = encodeVarintIcqoracle(dAtA, i, uint64(m.IcqTimeoutSec)) - i-- - dAtA[i] = 0x28 - } if m.PriceExpirationTimeoutSec != 0 { i = encodeVarintIcqoracle(dAtA, i, uint64(m.PriceExpirationTimeoutSec)) i-- @@ -475,7 +479,9 @@ func (m *TokenPrice) Size() (n int) { } l = m.SpotPrice.Size() n += 1 + l + sovIcqoracle(uint64(l)) - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRequestTime) + n += 1 + l + sovIcqoracle(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastResponseTime) n += 1 + l + sovIcqoracle(uint64(l)) if m.QueryInProgress { n += 2 @@ -503,9 +509,6 @@ func (m *Params) Size() (n int) { if m.PriceExpirationTimeoutSec != 0 { n += 1 + sovIcqoracle(uint64(m.PriceExpirationTimeoutSec)) } - if m.IcqTimeoutSec != 0 { - n += 1 + sovIcqoracle(uint64(m.IcqTimeoutSec)) - } return n } @@ -778,7 +781,7 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastRequestTime", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -805,11 +808,44 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastRequestTime, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastResponseTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIcqoracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthIcqoracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthIcqoracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastResponseTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", wireType) } @@ -981,25 +1017,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IcqTimeoutSec", wireType) - } - m.IcqTimeoutSec = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIcqoracle - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.IcqTimeoutSec |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipIcqoracle(dAtA[iNdEx:]) diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 14b223d523..161da4c09c 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -441,10 +441,12 @@ type TokenPriceResponse struct { OsmosisPoolId string `protobuf:"bytes,9,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` // Spot price of base_denom denominated in quote_denom SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,10,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` - // Last update timestamp - UpdatedAt time.Time `protobuf:"bytes,11,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + // Last time a query request was submitted + LastRequestTime time.Time `protobuf:"bytes,11,opt,name=last_request_time,json=lastRequestTime,proto3,stdtime" json:"last_request_time"` + // Last time a query response was received + LastResponseTime time.Time `protobuf:"bytes,12,opt,name=last_response_time,json=lastResponseTime,proto3,stdtime" json:"last_response_time"` // Whether there is a spot price query currently in progress - QueryInProgress bool `protobuf:"varint,12,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` + QueryInProgress bool `protobuf:"varint,13,opt,name=query_in_progress,json=queryInProgress,proto3" json:"query_in_progress,omitempty"` } func (m *TokenPriceResponse) Reset() { *m = TokenPriceResponse{} } @@ -543,9 +545,16 @@ func (m *TokenPriceResponse) GetOsmosisPoolId() string { return "" } -func (m *TokenPriceResponse) GetUpdatedAt() time.Time { +func (m *TokenPriceResponse) GetLastRequestTime() time.Time { if m != nil { - return m.UpdatedAt + return m.LastRequestTime + } + return time.Time{} +} + +func (m *TokenPriceResponse) GetLastResponseTime() time.Time { + if m != nil { + return m.LastResponseTime } return time.Time{} } @@ -572,62 +581,64 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 880 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xce, 0xe6, 0xc3, 0x8d, 0x5f, 0x17, 0xb5, 0x99, 0x04, 0xb2, 0x98, 0xd6, 0xb6, 0xb6, 0x69, - 0x08, 0x11, 0x9d, 0xa5, 0xa9, 0xda, 0x3b, 0x26, 0x2a, 0xaa, 0x68, 0x24, 0x77, 0x29, 0x17, 0x2e, - 0xd6, 0x78, 0x77, 0xba, 0x5d, 0xc5, 0xbb, 0xb3, 0xde, 0x19, 0xb7, 0xe4, 0xda, 0x03, 0xe7, 0x4a, - 0xfc, 0x10, 0x24, 0x7e, 0x01, 0xc7, 0x1e, 0x2b, 0x71, 0x00, 0x71, 0x28, 0x28, 0xe1, 0x87, 0xa0, - 0xf9, 0xd8, 0x0f, 0x77, 0x1d, 0x9c, 0x48, 0x9c, 0xba, 0x7e, 0x3f, 0x9f, 0xe7, 0x7d, 0xdf, 0x79, - 0x1a, 0xb8, 0xc1, 0x45, 0x16, 0x05, 0xd4, 0x8d, 0xfc, 0x09, 0xcb, 0x88, 0x3f, 0xa6, 0xee, 0x64, - 0x4a, 0xb3, 0x13, 0x9c, 0x66, 0x4c, 0x30, 0x74, 0x5d, 0x7b, 0x71, 0xe1, 0x6d, 0xef, 0xfb, 0x8c, - 0xc7, 0x8c, 0xbb, 0x23, 0xc2, 0x4d, 0xa8, 0xfb, 0xe2, 0xee, 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- 0xf9, 0xbd, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xb6, 0x1f, 0xa4, 0xc3, 0xf4, 0x08, 0x00, 0x00, + // 902 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcb, 0x6e, 0xdb, 0x46, + 0x14, 0x35, 0xfd, 0x50, 0xac, 0xab, 0x04, 0xb6, 0xc7, 0x6e, 0xcd, 0xaa, 0x89, 0x24, 0x30, 0x8e, + 0xeb, 0x1a, 0xcd, 0xb0, 0x71, 0x90, 0x7c, 0x80, 0x60, 0xa4, 0x08, 0x1a, 0x03, 0x0a, 0x9b, 0x6e, + 0xba, 0x11, 0x46, 0xe4, 0x84, 0x21, 0x2c, 0x72, 0x28, 0xce, 0x28, 0xa9, 0xb7, 0x59, 0x74, 0x1d, + 0xa0, 0x1f, 0x52, 0xa0, 0xab, 0x2e, 0xbb, 0xcc, 0x32, 0x40, 0x37, 0x45, 0x17, 0x69, 0x61, 0xf7, + 0x43, 0x8a, 0x79, 0xf0, 0xa1, 0xd0, 0xae, 0x6c, 0x20, 0x2b, 0x4b, 0xf7, 0x79, 0xce, 0xbd, 0x77, + 0x8e, 0x0c, 0x37, 0xb9, 0xc8, 0xa2, 0x80, 0xba, 0x91, 0x3f, 0x61, 0x19, 0xf1, 0xc7, 0xd4, 0x9d, + 0x4c, 0x69, 0x76, 0x82, 0xd3, 0x8c, 0x09, 0x86, 0xd6, 0xb5, 0x17, 0x17, 0xde, 0xf6, 0xbe, 0xcf, + 0x78, 0xcc, 0xb8, 0x3b, 0x22, 0xdc, 0x84, 0xba, 0x2f, 0xef, 0x8d, 0xa8, 0x20, 0xf7, 0xdc, 0x94, + 0x84, 0x51, 0x42, 0x44, 0xc4, 0x12, 0x9d, 0xdd, 0xde, 0x0a, 0x59, 0xc8, 0xd4, 0x47, 0x57, 0x7e, + 0x32, 0xd6, 0x9b, 0x21, 0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00, 0xff, 0xff, 0x57, 0xeb, + 0xa3, 0x7d, 0x55, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1141,15 +1152,23 @@ func (m *TokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x60 + dAtA[i] = 0x68 } - n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt):]) + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastResponseTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastResponseTime):]) if err5 != nil { return 0, err5 } i -= n5 i = encodeVarintQuery(dAtA, i, uint64(n5)) i-- + dAtA[i] = 0x62 + n6, err6 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.LastRequestTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRequestTime):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintQuery(dAtA, i, uint64(n6)) + i-- dAtA[i] = 0x5a { size := m.SpotPrice.Size() @@ -1388,7 +1407,9 @@ func (m *TokenPriceResponse) Size() (n int) { } l = m.SpotPrice.Size() n += 1 + l + sovQuery(uint64(l)) - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UpdatedAt) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastRequestTime) + n += 1 + l + sovQuery(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.LastResponseTime) n += 1 + l + sovQuery(uint64(l)) if m.QueryInProgress { n += 2 @@ -2495,7 +2516,7 @@ func (m *TokenPriceResponse) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 11: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastRequestTime", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2522,11 +2543,44 @@ func (m *TokenPriceResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastRequestTime, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastResponseTime", 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_cosmos_gogoproto_types.StdTimeUnmarshal(&m.LastResponseTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field QueryInProgress", wireType) } diff --git a/x/interchainquery/keeper/events.go b/x/interchainquery/keeper/events.go new file mode 100644 index 0000000000..99fd17b03d --- /dev/null +++ b/x/interchainquery/keeper/events.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v25/x/interchainquery/types" +) + +// Emits an event when a ICQ response is submitted +func EmitEventQueryResponse(ctx sdk.Context, query types.Query) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyQueryId, query.Id), + ), + sdk.NewEvent( + types.EventTypeQueryResponse, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeyQueryId, query.Id), + sdk.NewAttribute(types.AttributeKeyChainId, query.ChainId), + ), + }) +} diff --git a/x/interchainquery/keeper/msg_server.go b/x/interchainquery/keeper/msg_server.go index 45d9be4f2e..618e22efff 100644 --- a/x/interchainquery/keeper/msg_server.go +++ b/x/interchainquery/keeper/msg_server.go @@ -172,23 +172,12 @@ func (k msgServer) SubmitQueryResponse(goCtx context.Context, msg *types.MsgSubm // check if the response has an associated query stored on stride query, found := k.GetQuery(ctx, msg.QueryId) if !found { - k.Logger(ctx).Info("ICQ RESPONSE | Ignoring non-existent query response (note: duplicate responses are nonexistent)") + k.Logger(ctx).Error("ICQ RESPONSE | Ignoring non-existent query response (note: duplicate responses are nonexistent)") return &types.MsgSubmitQueryResponseResponse{}, nil // technically this is an error, but will cause the entire tx to fail if we have one 'bad' message, so we can just no-op here. } - defer ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(types.AttributeKeyQueryId, query.Id), - ), - sdk.NewEvent( - "query_response", - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(types.AttributeKeyQueryId, query.Id), - sdk.NewAttribute(types.AttributeKeyChainId, query.ChainId), - ), - }) + // Emit an event for the relayer + EmitEventQueryResponse(ctx, query) // Verify the response's proof, if one exists err := k.VerifyKeyProof(ctx, msg, query) diff --git a/x/interchainquery/types/error.go b/x/interchainquery/types/error.go index c4780f68b8..0e773acaeb 100644 --- a/x/interchainquery/types/error.go +++ b/x/interchainquery/types/error.go @@ -10,4 +10,5 @@ var ( ErrInvalidConsensusState = errors.New("invalid consensus state") ErrInvalidICQRequest = errors.New("invalid interchain query request") ErrFailedToRetryQuery = errors.New("failed to retry query") + ErrQueryNotFound = errors.New("Query not found") ) diff --git a/x/interchainquery/types/events.go b/x/interchainquery/types/events.go index d5dec6cc27..8287df4ada 100644 --- a/x/interchainquery/types/events.go +++ b/x/interchainquery/types/events.go @@ -11,4 +11,6 @@ const ( AttributeValueCategory = ModuleName AttributeValueQuery = "query" + + EventTypeQueryResponse = "query_response" ) From 8d949ab058aeb90bee1b7779873567fa7da9745e Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Feb 2025 13:22:18 -0600 Subject: [PATCH 111/115] fixed comments --- x/icqoracle/keeper/abci.go | 4 ++-- x/icqoracle/types/genesis.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index fa2b20dcfa..0815536e48 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -22,8 +22,8 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { updateIntervalPassed := currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) // If never updated or update interval has passed, submit a new query for the price - // If a query was already in progress, it will be replaced with this new one that will - // will have the same query ID + // If a query was already in progress, it will be replaced with a new one that will + // have the same query ID if isNewToken || updateIntervalPassed { if err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice); err != nil { ctx.Logger().Error( diff --git a/x/icqoracle/types/genesis.go b/x/icqoracle/types/genesis.go index 2a93b3e5a2..02aeffd24c 100644 --- a/x/icqoracle/types/genesis.go +++ b/x/icqoracle/types/genesis.go @@ -11,7 +11,6 @@ func DefaultGenesis() *GenesisState { // Performs basic genesis state validation by iterating through all token prices and validating // using ValidateTokenPriceQueryParams(). -// We ignore the SpotPrice, LastRequestTime & QueryInProgress fields since they are reset in InitGenesis(). func (gs GenesisState) Validate() error { for i, tokenPrice := range gs.TokenPrices { err := ValidateTokenPriceQueryParams( From 6904256bdb3d3c388b1a4d441529836d160bcddf Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Feb 2025 14:39:39 -0600 Subject: [PATCH 112/115] moved abci stuff to own func (#1348) --- x/icqoracle/keeper/abci.go | 57 +++++++++++++++++++------------ x/icqoracle/keeper/abci_test.go | 40 +++------------------- x/icqoracle/keeper/keeper_test.go | 7 ---- 3 files changed, 40 insertions(+), 64 deletions(-) diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index 0815536e48..60fb2e44d1 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -1,40 +1,53 @@ package keeper import ( + "fmt" "time" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v25/x/icqoracle/types" ) func (k Keeper) BeginBlocker(ctx sdk.Context) { params, err := k.GetParams(ctx) if err != nil { - ctx.Logger().Error("failed to get icqoracle params: %w", err) + ctx.Logger().Error("Unable to fetch params") return } - currentTime := ctx.BlockTime() - for _, tokenPrice := range k.GetAllTokenPrices(ctx) { - // Get last update time for this token - lastUpdate := tokenPrice.LastRequestTime - isNewToken := lastUpdate.IsZero() - updateIntervalPassed := currentTime.Sub(lastUpdate) >= time.Second*time.Duration(params.UpdateIntervalSec) - - // If never updated or update interval has passed, submit a new query for the price - // If a query was already in progress, it will be replaced with a new one that will - // have the same query ID - if isNewToken || updateIntervalPassed { - if err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice); err != nil { - ctx.Logger().Error( - "failed to submit Osmosis CL pool ICQ baseToken='%s' quoteToken='%s' poolId='%s': %w", - tokenPrice.BaseDenom, - tokenPrice.QuoteDenom, - tokenPrice.OsmosisPoolId, - err, - ) - continue - } + if err := k.RefreshTokenPrice(ctx, tokenPrice, params.UpdateIntervalSec); err != nil { + ctx.Logger().Error(fmt.Sprintf("failed to refresh token price: %s", err.Error())) + continue } } } + +// Refreshes the price of a token (if applicable) +func (k Keeper) RefreshTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice, updateIntervalSec uint64) error { + // Get last update time for this token + currentTime := ctx.BlockTime() + lastUpdate := tokenPrice.LastRequestTime + isNewToken := lastUpdate.IsZero() + updateIntervalPassed := currentTime.Sub(lastUpdate) >= time.Second*time.Duration(updateIntervalSec) + + // If the update interval has not passed, don't update + if !isNewToken && !updateIntervalPassed { + return nil + } + + // If never updated or update interval has passed, submit a new query for the price + // If a query was already in progress, it will be replaced with a new one that will + // have the same query ID + if err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice); err != nil { + return errorsmod.Wrapf(err, + "failed to submit Osmosis CL pool ICQ baseToken='%s' quoteToken='%s' poolId='%s'", + tokenPrice.BaseDenom, + tokenPrice.QuoteDenom, + tokenPrice.OsmosisPoolId) + } + + return nil +} diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go index cec75610f6..68233e6b1a 100644 --- a/x/icqoracle/keeper/abci_test.go +++ b/x/icqoracle/keeper/abci_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "fmt" - "strings" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,23 +10,6 @@ import ( icqtypes "github.com/Stride-Labs/stride/v25/x/interchainquery/types" ) -func (s *KeeperTestSuite) TestBeginBlockerParams() { - // Delete params from store - s.DeleteParams() - - // Run BeginBlocker with missing params - s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) - - // Get the logged output - logOutput := s.logBuffer.String() - - // Verify the error was logged - s.Require().True( - strings.Contains(logOutput, "failed to get icqoracle params"), - "expected error log message about missing params, got: %s", logOutput, - ) -} - func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { var submitICQCalled bool @@ -134,34 +116,22 @@ func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { } s.App.ICQOracleKeeper.IcqKeeper = s.mockICQKeeper - // Set params - params := types.Params{ - UpdateIntervalSec: 60, - } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) - // Create token price that needs updating + updateIntervalSec := uint64(60) tokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", OsmosisPoolId: "1", LastRequestTime: time.Time{}, // Zero time to trigger update } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err) // Run BeginBlocker - should log error but continue - s.App.ICQOracleKeeper.BeginBlocker(s.Ctx) - - // Get the logged output and verify error was logged - logOutput := s.logBuffer.String() - s.Require().True( - strings.Contains(logOutput, "icq submit failed"), - "expected error log message about ICQ submission failure, got: %s", logOutput, - ) + err = s.App.ICQOracleKeeper.RefreshTokenPrice(s.Ctx, tokenPrice, updateIntervalSec) + s.Require().ErrorContains(err, "failed to submit Osmosis CL pool ICQ") - // Verify token price was not modified + // Verify token price query was not submitted updatedPrice := s.MustGetTokenPrice( tokenPrice.BaseDenom, tokenPrice.QuoteDenom, diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index 998f5484bb..34b711a8e0 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -1,11 +1,9 @@ package keeper_test import ( - "bytes" "testing" "time" - "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" @@ -19,7 +17,6 @@ type KeeperTestSuite struct { apptesting.AppTestHelper mockICQKeeper types.IcqKeeper icqCallbacks keeper.ICQCallbacks - logBuffer bytes.Buffer } // Helper function to setup keeper with mock ICQ keeper @@ -45,10 +42,6 @@ func (s *KeeperTestSuite) SetupTest() { s.Require().True(s.icqCallbacks.HasICQCallback(keeper.ICQCallbackID_OsmosisClPool), "OsmosisClPool callback should be registered") - - // Create a logger with accessible output - logger := log.NewTMLogger(&s.logBuffer) - s.Ctx = s.Ctx.WithLogger(logger) } // Dynamically gets the MsgServer for this module's keeper From 61318fb067bcc5e4b13d11520b85459909ef73b4 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Feb 2025 14:41:33 -0600 Subject: [PATCH 113/115] Osmo pool id type (#1346) Co-authored-by: Assaf Morami --- proto/stride/icqoracle/icqoracle.proto | 2 +- proto/stride/icqoracle/query.proto | 4 +- proto/stride/icqoracle/tx.proto | 4 +- utils/utils.go | 10 +- x/auction/keeper/msg_server_test.go | 8 +- x/icqoracle/client/cli/query.go | 10 +- x/icqoracle/client/cli/tx.go | 14 +- x/icqoracle/keeper/abci_test.go | 16 +-- x/icqoracle/keeper/icq.go | 8 +- x/icqoracle/keeper/icq_test.go | 56 +++----- x/icqoracle/keeper/keeper.go | 8 +- x/icqoracle/keeper/keeper_test.go | 2 +- x/icqoracle/keeper/msg_server.go | 2 +- x/icqoracle/keeper/msg_server_test.go | 4 +- x/icqoracle/keeper/query_test.go | 36 ++--- x/icqoracle/types/icqoracle.pb.go | 90 +++++------- x/icqoracle/types/keys.go | 8 +- x/icqoracle/types/msgs.go | 9 +- x/icqoracle/types/query.pb.go | 186 ++++++++++--------------- x/icqoracle/types/tx.pb.go | 142 ++++++++----------- x/icqoracle/types/validate.go | 7 +- 21 files changed, 267 insertions(+), 359 deletions(-) diff --git a/proto/stride/icqoracle/icqoracle.proto b/proto/stride/icqoracle/icqoracle.proto index 628e729c82..27a9a9cc7b 100644 --- a/proto/stride/icqoracle/icqoracle.proto +++ b/proto/stride/icqoracle/icqoracle.proto @@ -21,7 +21,7 @@ message TokenPrice { // Quote denom on Osmosis string osmosis_quote_denom = 6; // Pool ID on Osmosis - string osmosis_pool_id = 7; + uint64 osmosis_pool_id = 7; // Spot price of base_denom denominated in quote_denom string spot_price = 8 [ diff --git a/proto/stride/icqoracle/query.proto b/proto/stride/icqoracle/query.proto index 441ef9f08a..1313f64aed 100644 --- a/proto/stride/icqoracle/query.proto +++ b/proto/stride/icqoracle/query.proto @@ -38,7 +38,7 @@ service Query { message QueryTokenPriceRequest { string base_denom = 1; string quote_denom = 2; - string pool_id = 3; + uint64 pool_id = 3; } // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC @@ -103,7 +103,7 @@ message TokenPriceResponse { // Quote denom on Osmosis string osmosis_quote_denom = 8; // Pool ID on Osmosis - string osmosis_pool_id = 9; + uint64 osmosis_pool_id = 9; // Spot price of base_denom denominated in quote_denom string spot_price = 10 [ diff --git a/proto/stride/icqoracle/tx.proto b/proto/stride/icqoracle/tx.proto index 624088031f..1ee23107e1 100644 --- a/proto/stride/icqoracle/tx.proto +++ b/proto/stride/icqoracle/tx.proto @@ -41,7 +41,7 @@ message MsgRegisterTokenPriceQuery { // Quote denom on Osmosis string osmosis_quote_denom = 7; // Pool ID on Osmosis - string osmosis_pool_id = 8; + uint64 osmosis_pool_id = 8; } message MsgRegisterTokenPriceQueryResponse {} @@ -58,7 +58,7 @@ message MsgRemoveTokenPriceQuery { // Quote denom on Stride string quote_denom = 3; // Pool ID on Osmosis - string osmosis_pool_id = 4; + uint64 osmosis_pool_id = 4; } message MsgRemoveTokenPriceQueryResponse {} \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index feb24f7054..72cee9bf18 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -233,10 +233,10 @@ func LogWithHostZone(chainId string, s string, a ...any) string { // Ex: // // | uosmo/ustrd | string -func LogWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, s string, a ...any, +func LogWithTokenPriceQuery(baseDenom, quoteDenom string, osmosisPoolId uint64, s string, a ...any, ) string { msg := fmt.Sprintf(s, a...) - return fmt.Sprintf("| %s/%s/%s | %s", baseDenom, quoteDenom, osmosisPoolId, msg) + return fmt.Sprintf("| %s/%s/%d | %s", baseDenom, quoteDenom, osmosisPoolId, msg) } // Returns a log string with a chain Id and callback as a prefix @@ -244,9 +244,9 @@ func LogWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, s string, a .. // Format: // // | uosmo/ustrd | {CALLBACK_ID} {CALLBACK_TYPE} | string -func logCallbackWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, callbackId string, callbackType string, s string, a ...any) string { +func logCallbackWithTokenPriceQuery(baseDenom, quoteDenom string, osmosisPoolId uint64, callbackId string, callbackType string, s string, a ...any) string { msg := fmt.Sprintf(s, a...) - return fmt.Sprintf("| %s/%s/%s | %s %s | %s", baseDenom, quoteDenom, osmosisPoolId, strings.ToUpper(callbackId), callbackType, msg) + return fmt.Sprintf("| %s/%s/%d | %s %s | %s", baseDenom, quoteDenom, osmosisPoolId, strings.ToUpper(callbackId), callbackType, msg) } // Returns a log string with a chain Id and callback as a prefix @@ -296,7 +296,7 @@ func LogICQCallbackWithHostZone(chainId string, callbackId string, s string, a . // Ex: // // | COSMOSHUB-4 | WITHDRAWALHOSTBALANCE ICQCALLBACK | string -func LogICQCallbackWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, callbackId string, s string, a ...any) string { +func LogICQCallbackWithTokenPriceQuery(baseDenom, quoteDenom string, osmosisPoolId uint64, callbackId string, s string, a ...any) string { return logCallbackWithTokenPriceQuery(baseDenom, quoteDenom, osmosisPoolId, callbackId, "ICQCALLBACK", s, a...) } diff --git a/x/auction/keeper/msg_server_test.go b/x/auction/keeper/msg_server_test.go index 37bfd89c7b..243bcb19da 100644 --- a/x/auction/keeper/msg_server_test.go +++ b/x/auction/keeper/msg_server_test.go @@ -104,7 +104,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidHappyPath() { tokenPrice := icqoracletypes.TokenPrice{ BaseDenom: auction.SellingDenom, QuoteDenom: auction.PaymentDenom, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1), LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, @@ -294,7 +294,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { tokenPrice := icqoracletypes.TokenPrice{ BaseDenom: auction.SellingDenom, QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1), LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, @@ -339,7 +339,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { tokenPrice := icqoracletypes.TokenPrice{ BaseDenom: auction.SellingDenom, QuoteDenom: auction.PaymentDenom, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1), LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, @@ -390,7 +390,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { tokenPrice := icqoracletypes.TokenPrice{ BaseDenom: auction.SellingDenom, QuoteDenom: auction.PaymentDenom, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1), LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, diff --git a/x/icqoracle/client/cli/query.go b/x/icqoracle/client/cli/query.go index a7456a476d..cbffd94629 100644 --- a/x/icqoracle/client/cli/query.go +++ b/x/icqoracle/client/cli/query.go @@ -3,6 +3,7 @@ package cli import ( "context" "fmt" + "strconv" "github.com/spf13/cobra" @@ -32,12 +33,16 @@ func GetQueryCmd() *cobra.Command { func CmdQueryTokenPrice() *cobra.Command { cmd := &cobra.Command{ - Use: "token-price [base-denom] [quote-denom]", + Use: "token-price [base-denom] [quote-denom] [pool-id]", Short: "Query the current price for a specific token", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { baseDenom := args[0] quoteDenom := args[1] + poolId, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return fmt.Errorf("Error parsing osmosis pool ID as uint64: %w", err) + } clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -48,6 +53,7 @@ func CmdQueryTokenPrice() *cobra.Command { req := &types.QueryTokenPriceRequest{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, + PoolId: poolId, } res, err := queryClient.TokenPrice(context.Background(), req) if err != nil { diff --git a/x/icqoracle/client/cli/tx.go b/x/icqoracle/client/cli/tx.go index 6f0ea8cf9c..ff49d0308b 100644 --- a/x/icqoracle/client/cli/tx.go +++ b/x/icqoracle/client/cli/tx.go @@ -60,13 +60,18 @@ Example: return fmt.Errorf("Error parsing quoteDenomDecmnals as int64: %w", err) } + osmosisPoolId, err := strconv.ParseUint(args[4], 10, 64) + if err != nil { + return fmt.Errorf("Error parsing osmosis pool ID as uint64: %w", err) + } + msg := types.NewMsgRegisterTokenPriceQuery( clientCtx.GetFromAddress().String(), args[0], args[1], baseDenomDecimls, quoteDenomDecimls, - args[4], + osmosisPoolId, args[5], args[6], ) @@ -102,11 +107,16 @@ Example: return err } + osmosisPoolId, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return fmt.Errorf("Error parsing osmosis pool ID as uint64: %w", err) + } + msg := types.NewMsgRemoveTokenPriceQuery( clientCtx.GetFromAddress().String(), args[0], args[1], - args[2], + osmosisPoolId, ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go index 68233e6b1a..a65e7c27e6 100644 --- a/x/icqoracle/keeper/abci_test.go +++ b/x/icqoracle/keeper/abci_test.go @@ -39,7 +39,7 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, LastRequestTime: time.Time{}, // Zero time }, expectedICQSubmit: true, @@ -49,7 +49,7 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { tokenPrice: types.TokenPrice{ BaseDenom: "uosmo", QuoteDenom: "uusdc", - OsmosisPoolId: "2", + OsmosisPoolId: 2, LastRequestTime: staleTime, }, expectedICQSubmit: true, @@ -59,7 +59,7 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { tokenPrice: types.TokenPrice{ BaseDenom: "ustrd", QuoteDenom: "uusdc", - OsmosisPoolId: "3", + OsmosisPoolId: 3, LastRequestTime: freshTime, }, expectedICQSubmit: false, @@ -121,7 +121,7 @@ func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { tokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, LastRequestTime: time.Time{}, // Zero time to trigger update } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) @@ -168,28 +168,28 @@ func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { { BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, LastRequestTime: staleTime, QueryInProgress: false, }, { BaseDenom: "uosmo", QuoteDenom: "uusdc", - OsmosisPoolId: "2", + OsmosisPoolId: 2, LastRequestTime: staleTime, QueryInProgress: false, }, { BaseDenom: "ustrd", QuoteDenom: "uusdc", - OsmosisPoolId: "3", + OsmosisPoolId: 3, LastRequestTime: s.Ctx.BlockTime(), // Should skip this one QueryInProgress: true, }, { BaseDenom: "ustrd", QuoteDenom: "uusdc", - OsmosisPoolId: "4", + OsmosisPoolId: 4, LastRequestTime: s.Ctx.BlockTime(), // Should skip this one QueryInProgress: false, }, diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 575616d279..30ac1c2274 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -3,7 +3,6 @@ package keeper import ( "encoding/hex" "fmt" - "strconv" "time" errorsmod "cosmossdk.io/errors" @@ -66,11 +65,6 @@ func (k Keeper) SubmitOsmosisClPoolICQ( return errorsmod.Wrap(err, "Error getting module params") } - osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) - if err != nil { - return errorsmod.Wrapf(err, "Error converting osmosis pool id '%s' to uint64", tokenPrice.OsmosisPoolId) - } - tokenPriceBz, err := k.cdc.Marshal(&tokenPrice) if err != nil { return errorsmod.Wrapf(err, "Error serializing tokenPrice '%+v' to bytes", tokenPrice) @@ -80,7 +74,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( ChainId: params.OsmosisChainId, ConnectionId: params.OsmosisConnectionId, QueryType: icqtypes.CONCENTRATEDLIQUIDITY_STORE_QUERY_WITH_PROOF, - RequestData: icqtypes.FormatOsmosisKeyPool(osmosisPoolId), + RequestData: icqtypes.FormatOsmosisKeyPool(tokenPrice.OsmosisPoolId), CallbackModule: types.ModuleName, CallbackId: ICQCallbackID_OsmosisClPool, CallbackData: tokenPriceBz, diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index 1389455fd2..ffa34fffde 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "fmt" - "strconv" "time" "cosmossdk.io/math" @@ -33,7 +32,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQUnknownPrice() { tokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, } params := types.Params{ @@ -65,7 +64,7 @@ func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { tokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) @@ -106,25 +105,6 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { tokenPrice types.TokenPrice expectedError string }{ - { - name: "error parsing pool ID", - setup: func() { - // Set valid params - params := types.Params{ - OsmosisChainId: "osmosis-1", - OsmosisConnectionId: "connection-0", - UpdateIntervalSec: 60, - } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) - }, - tokenPrice: types.TokenPrice{ - BaseDenom: "uatom", - QuoteDenom: "uusdc", - OsmosisPoolId: "invalid_pool_id", // NaN invalid pool ID - }, - expectedError: "Error converting osmosis pool id", - }, { name: "error submitting ICQ request", setup: func() { @@ -147,7 +127,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, }, expectedError: "Error submitting OsmosisClPool ICQ", }, @@ -166,7 +146,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { s.mockICQKeeper = MockICQKeeper{ SubmitICQRequestFn: func(ctx sdk.Context, query icqtypes.Query, forceUnique bool) error { // Remove token price so set query in progress will fail to get it after SubmitICQRequest returns - s.App.ICQOracleKeeper.RemoveTokenPrice(ctx, "uatom", "uusdc", "1") + s.App.ICQOracleKeeper.RemoveTokenPrice(ctx, "uatom", "uusdc", 1) return nil }, } @@ -177,7 +157,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, }, expectedError: "Error updating token price query to in progress", }, @@ -203,7 +183,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, }, expectedError: "", }, @@ -264,7 +244,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { tokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, } err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) s.Require().NoError(err) @@ -289,9 +269,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { s.Require().Equal(keeper.ICQCallbackID_OsmosisClPool, capturedQuery.CallbackId) // Verify request data format (pool key) - osmosisPoolId, err := strconv.ParseUint(tokenPrice.OsmosisPoolId, 10, 64) - s.Require().NoError(err) - expectedRequestData := icqtypes.FormatOsmosisKeyPool(osmosisPoolId) + expectedRequestData := icqtypes.FormatOsmosisKeyPool(tokenPrice.OsmosisPoolId) s.Require().Equal(expectedRequestData, capturedQuery.RequestData) // Verify callback data contains the token price @@ -328,7 +306,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { baseTokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "ibc/uusdc", SpotPrice: math.LegacyNewDec(2), @@ -477,7 +455,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { CallbackData: []byte{}, } }, - expectedError: "price not found for baseDenom='' quoteDenom='' poolId=''", + expectedError: "price not found for baseDenom='' quoteDenom='' poolId='0'", }, { name: "nil query callback data", @@ -486,7 +464,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { CallbackData: nil, } }, - expectedError: "price not found for baseDenom='' quoteDenom='' poolId=''", + expectedError: "price not found for baseDenom='' quoteDenom='' poolId='0'", }, { name: "corrupted token price in callback data", @@ -642,7 +620,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { } }, expectedError: fmt.Sprintf( - "price not found for baseDenom='%s' quoteDenom='%s' poolId='%s'", + "price not found for baseDenom='%s' quoteDenom='%s' poolId='%d'", baseTokenPrice.BaseDenom, baseTokenPrice.QuoteDenom, baseTokenPrice.OsmosisPoolId), @@ -680,7 +658,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { baseTokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "uusdc", BaseDenomDecimals: 6, @@ -714,7 +692,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { tokenPrice: types.TokenPrice{ BaseDenom: "satoshi", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/satoshi", OsmosisQuoteDenom: "ibc/uusdc", BaseDenomDecimals: 8, // BTC has 8 decimals @@ -731,7 +709,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "ibc/uusdc", BaseDenomDecimals: 6, // ATOM has 6 decimals @@ -748,7 +726,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "ibc/uusdc", BaseDenomDecimals: 8, @@ -765,7 +743,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { tokenPrice: types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "different_denom", BaseDenomDecimals: 6, diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index efc9178252..18d8f61f7e 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -55,14 +55,14 @@ func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) erro } // RemoveTokenPrice removes price query for a token -func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) { +func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) store.Delete(key) } // Updates the token price when a query is requested -func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) error { +func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) error { tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom, osmosisPoolId) if err != nil { return err @@ -93,13 +93,13 @@ func (k Keeper) SetTokenPriceQueryComplete(ctx sdk.Context, tokenPrice types.Tok } // GetTokenPrice retrieves price data for a token -func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId string) (types.TokenPrice, error) { +func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) (types.TokenPrice, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) bz := store.Get(key) if bz == nil { - return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%s'", baseDenom, quoteDenom, osmosisPoolId) + return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%d'", baseDenom, quoteDenom, osmosisPoolId) } var price types.TokenPrice diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index 34b711a8e0..47f1b5e8c9 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -58,7 +58,7 @@ func TestKeeperTestSuite(t *testing.T) { } // Helper function to get a token price and confirm there's no error -func (s *KeeperTestSuite) MustGetTokenPrice(baseDenom string, quoteDenom string, osmosisPoolId string) types.TokenPrice { +func (s *KeeperTestSuite) MustGetTokenPrice(baseDenom string, quoteDenom string, osmosisPoolId uint64) types.TokenPrice { tp, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, baseDenom, quoteDenom, osmosisPoolId) s.Require().NoError(err, "no error expected when getting token price") return tp diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index 040bd36c0b..8585da06ef 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -28,7 +28,7 @@ func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.Ms _, err := ms.Keeper.GetTokenPrice(ctx, msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) if err == nil { - return nil, types.ErrTokenPriceAlreadyExists.Wrapf("token price BaseDenom='%s' QuoteDenom='%s' OsmosisPoolId='%s'", msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) + return nil, types.ErrTokenPriceAlreadyExists.Wrapf("token price BaseDenom='%s' QuoteDenom='%s' OsmosisPoolId='%d'", msg.BaseDenom, msg.QuoteDenom, msg.OsmosisPoolId) } tokenPrice := types.TokenPrice{ diff --git a/x/icqoracle/keeper/msg_server_test.go b/x/icqoracle/keeper/msg_server_test.go index 5745856005..8e3b9d83bd 100644 --- a/x/icqoracle/keeper/msg_server_test.go +++ b/x/icqoracle/keeper/msg_server_test.go @@ -14,7 +14,7 @@ func (s *KeeperTestSuite) TestRegisterTokenPriceQuery() { msg := types.MsgRegisterTokenPriceQuery{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "uusdc", } @@ -43,7 +43,7 @@ func (s *KeeperTestSuite) TestRemoveTokenPriceQuery() { tokenPrice := types.TokenPrice{ BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, OsmosisBaseDenom: "ibc/uatom", OsmosisQuoteDenom: "uusdc", SpotPrice: sdkmath.LegacyNewDec(1), diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index a176d23ca8..56aa1956f8 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -13,7 +13,7 @@ func (s *KeeperTestSuite) TestQueryTokenPrice() { // Create token price entry baseDenom := "uatom" quoteDenom := "uusdc" - poolId := "1" + poolId := uint64(1) expectedPrice := sdkmath.LegacyNewDec(1000000) tokenPrice := types.TokenPrice{ @@ -43,7 +43,7 @@ func (s *KeeperTestSuite) TestQueryTokenPrice() { req = &types.QueryTokenPriceRequest{ BaseDenom: "banana", QuoteDenom: "papaya", - PoolId: "1", + PoolId: 1, } _, err = s.App.ICQOracleKeeper.TokenPrice(sdk.WrapSDKContext(s.Ctx), req) s.Require().Error(err, "error expected when querying non existing token price") @@ -55,13 +55,13 @@ func (s *KeeperTestSuite) TestQueryTokenPrices() { { BaseDenom: "uatom", QuoteDenom: "uusdc", - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), }, { BaseDenom: "uosmo", QuoteDenom: "uusdc", - OsmosisPoolId: "2", + OsmosisPoolId: 2, SpotPrice: sdkmath.LegacyNewDec(2000000), }, } @@ -129,7 +129,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { tokenPrice := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: expectedPrice, LastRequestTime: s.Ctx.BlockTime(), } @@ -175,7 +175,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { tokenPrice1 := types.TokenPrice{ BaseDenom: baseDenom1, QuoteDenom: quoteDenom, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: expectedPrice1, LastRequestTime: s.Ctx.BlockTime(), } @@ -186,7 +186,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { tokenPrice2 := types.TokenPrice{ BaseDenom: baseDenom2, QuoteDenom: quoteDenom, - OsmosisPoolId: "2", + OsmosisPoolId: 2, SpotPrice: expectedPrice2, LastRequestTime: s.Ctx.BlockTime(), } @@ -219,7 +219,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { tokenPrice := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: expectedPrice, LastRequestTime: s.Ctx.BlockTime(), } @@ -249,7 +249,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { tokenPrice1 := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: intermediateQuote, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -260,7 +260,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { tokenPrice2 := types.TokenPrice{ BaseDenom: quoteDenom, QuoteDenom: intermediateQuote, - OsmosisPoolId: "2", + OsmosisPoolId: 2, SpotPrice: sdkmath.LegacyZeroDec(), LastRequestTime: s.Ctx.BlockTime(), } @@ -286,7 +286,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { tokenPrice1 := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: "quote1", - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -297,7 +297,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { tokenPrice2 := types.TokenPrice{ BaseDenom: quoteDenom, QuoteDenom: "quote2", - OsmosisPoolId: "2", + OsmosisPoolId: 2, SpotPrice: sdkmath.LegacyNewDec(2000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -323,7 +323,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomParamsError() { tokenPrice1 := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: "quote1", - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -355,7 +355,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoQuoteDenom() { tokenPrice1 := types.TokenPrice{ BaseDenom: "banana", QuoteDenom: "quote1", - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -388,7 +388,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { tokenPrice1 := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: intermediateQuote, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale } @@ -399,7 +399,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { tokenPrice2 := types.TokenPrice{ BaseDenom: quoteDenom, QuoteDenom: intermediateQuote, - OsmosisPoolId: "2", + OsmosisPoolId: 2, SpotPrice: sdkmath.LegacyNewDec(2000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -433,7 +433,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { tokenPrice1 := types.TokenPrice{ BaseDenom: baseDenom, QuoteDenom: intermediateQuote, - OsmosisPoolId: "1", + OsmosisPoolId: 1, SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } @@ -444,7 +444,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { tokenPrice2 := types.TokenPrice{ BaseDenom: quoteDenom, QuoteDenom: intermediateQuote, - OsmosisPoolId: "2", + OsmosisPoolId: 2, SpotPrice: sdkmath.LegacyNewDec(2000000), LastRequestTime: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale } diff --git a/x/icqoracle/types/icqoracle.pb.go b/x/icqoracle/types/icqoracle.pb.go index 1d7743da22..573eff2fe4 100644 --- a/x/icqoracle/types/icqoracle.pb.go +++ b/x/icqoracle/types/icqoracle.pb.go @@ -43,7 +43,7 @@ type TokenPrice struct { // Quote denom on Osmosis OsmosisQuoteDenom string `protobuf:"bytes,6,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,7,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + OsmosisPoolId uint64 `protobuf:"varint,7,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` // Spot price of base_denom denominated in quote_denom SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` // Last time a query request was submitted @@ -129,11 +129,11 @@ func (m *TokenPrice) GetOsmosisQuoteDenom() string { return "" } -func (m *TokenPrice) GetOsmosisPoolId() string { +func (m *TokenPrice) GetOsmosisPoolId() uint64 { if m != nil { return m.OsmosisPoolId } - return "" + return 0 } func (m *TokenPrice) GetLastRequestTime() time.Time { @@ -239,7 +239,7 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/icqoracle.proto", fileDescriptor_08ead8ab9516d7fc) } var fileDescriptor_08ead8ab9516d7fc = []byte{ - // 652 bytes of a gzipped FileDescriptorProto + // 655 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x3f, 0x6f, 0xd3, 0x40, 0x14, 0x8f, 0x69, 0x28, 0xcd, 0x55, 0xd0, 0xc6, 0x2d, 0x22, 0x84, 0x12, 0x47, 0xae, 0x84, 0x22, 0x04, 0x36, 0x6a, 0xd5, 0x01, 0x46, 0xb7, 0x08, 0x45, 0x2a, 0x52, 0x70, 0xbb, 0xc0, 0x62, 0x5d, @@ -256,31 +256,31 @@ var fileDescriptor_08ead8ab9516d7fc = []byte{ 0xfe, 0x06, 0x6c, 0xce, 0x05, 0xce, 0x0c, 0x75, 0x69, 0xd0, 0x67, 0xc9, 0x95, 0xe3, 0x15, 0xd0, 0x29, 0x8b, 0x28, 0x23, 0xcc, 0x9b, 0xeb, 0xf4, 0xbe, 0xec, 0x64, 0xbd, 0x60, 0x9c, 0xaa, 0x61, 0x0b, 0x6c, 0x94, 0xea, 0xf9, 0xc6, 0x97, 0xa5, 0xbc, 0x59, 0x50, 0x9f, 0x66, 0xfd, 0xbf, 0x00, - 0x6b, 0xa5, 0x3e, 0xa1, 0x34, 0xf4, 0x88, 0xdf, 0x7a, 0x20, 0xb5, 0x0f, 0x0b, 0x78, 0x40, 0x69, - 0xd8, 0xf7, 0x75, 0x07, 0x00, 0x96, 0x50, 0xee, 0x25, 0xe2, 0xd5, 0x5a, 0x2b, 0x42, 0xe2, 0x6c, - 0x5f, 0xe6, 0x46, 0xed, 0x57, 0x6e, 0x3c, 0x43, 0x52, 0xcb, 0xfc, 0x53, 0x8b, 0x50, 0x3b, 0x82, - 0xfc, 0xc4, 0x3a, 0xc4, 0x01, 0x44, 0xe3, 0x03, 0x8c, 0xdc, 0x86, 0xb0, 0xa9, 0xb7, 0x1e, 0x80, - 0x66, 0x08, 0x19, 0xf7, 0x52, 0x3c, 0xca, 0x30, 0xe3, 0x9e, 0x18, 0x4d, 0xab, 0xd1, 0xd5, 0x7a, - 0xab, 0x3b, 0x6d, 0x4b, 0xcd, 0xcd, 0x2a, 0xe7, 0x66, 0x1d, 0x97, 0x73, 0x73, 0x56, 0x44, 0x99, - 0x8b, 0xdf, 0x86, 0xe6, 0xae, 0x09, 0xbb, 0xab, 0xdc, 0x82, 0xd7, 0x5d, 0xa0, 0x17, 0x89, 0x2c, - 0xa1, 0x31, 0xc3, 0x2a, 0x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, 0x34, 0xdd, 0xa6, + 0x42, 0xfb, 0x05, 0x78, 0x84, 0x91, 0xfe, 0x4d, 0x03, 0x5b, 0x72, 0x9b, 0x3c, 0x7c, 0x9e, 0x90, + 0x14, 0xca, 0xa6, 0xc4, 0xfc, 0x68, 0xc6, 0x65, 0xc1, 0xba, 0x2c, 0xf8, 0x61, 0x92, 0x1b, 0x77, + 0xea, 0xa6, 0xb9, 0xb1, 0xad, 0x2a, 0xdf, 0xa5, 0x32, 0xdd, 0xa7, 0x92, 0x7e, 0x5f, 0xb1, 0xc7, + 0x8a, 0x3c, 0xc2, 0xc8, 0xf9, 0x78, 0x79, 0xdd, 0xd1, 0xae, 0xae, 0x3b, 0xda, 0x9f, 0xeb, 0x8e, + 0x76, 0x71, 0xd3, 0xa9, 0x5d, 0xdd, 0x74, 0x6a, 0x3f, 0x6f, 0x3a, 0xb5, 0x2f, 0xbb, 0x01, 0xe1, + 0x27, 0xd9, 0xd0, 0x42, 0x34, 0xb2, 0x8f, 0xe4, 0x05, 0x7a, 0x7d, 0x08, 0x87, 0xcc, 0x2e, 0xee, + 0xd5, 0xd9, 0xce, 0x9e, 0x7d, 0x3e, 0x77, 0xb5, 0xf8, 0x38, 0xc1, 0x6c, 0xb8, 0x2c, 0x37, 0x6e, + 0xf7, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0xe2, 0x80, 0x97, 0xd6, 0x04, 0x00, 0x00, } func (m *TokenPrice) Marshal() (dAtA []byte, err error) { @@ -339,12 +339,10 @@ func (m *TokenPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x42 - if len(m.OsmosisPoolId) > 0 { - i -= len(m.OsmosisPoolId) - copy(dAtA[i:], m.OsmosisPoolId) - i = encodeVarintIcqoracle(dAtA, i, uint64(len(m.OsmosisPoolId))) + if m.OsmosisPoolId != 0 { + i = encodeVarintIcqoracle(dAtA, i, uint64(m.OsmosisPoolId)) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x38 } if len(m.OsmosisQuoteDenom) > 0 { i -= len(m.OsmosisQuoteDenom) @@ -473,9 +471,8 @@ func (m *TokenPrice) Size() (n int) { if l > 0 { n += 1 + l + sovIcqoracle(uint64(l)) } - l = len(m.OsmosisPoolId) - if l > 0 { - n += 1 + l + sovIcqoracle(uint64(l)) + if m.OsmosisPoolId != 0 { + n += 1 + sovIcqoracle(uint64(m.OsmosisPoolId)) } l = m.SpotPrice.Size() n += 1 + l + sovIcqoracle(uint64(l)) @@ -714,10 +711,10 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 7: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } - var stringLen uint64 + m.OsmosisPoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIcqoracle @@ -727,24 +724,11 @@ func (m *TokenPrice) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.OsmosisPoolId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthIcqoracle - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIcqoracle - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", wireType) diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 044e1063a9..640111fa0b 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -1,6 +1,8 @@ package types -import fmt "fmt" +import ( + fmt "fmt" +) const ( ModuleName = "icqoracle" @@ -17,8 +19,8 @@ var ( PriceQueryPrefix = []byte("pricequery") ) -func TokenPriceKey(baseDenom, quoteDenom, poolId string) []byte { - return []byte(fmt.Sprintf("%s|%s|%s", baseDenom, quoteDenom, poolId)) +func TokenPriceKey(baseDenom, quoteDenom string, poolId uint64) []byte { + return []byte(fmt.Sprintf("%s|%s|%d", baseDenom, quoteDenom, poolId)) } func TokenPriceByDenomKey(baseDenom string) []byte { diff --git a/x/icqoracle/types/msgs.go b/x/icqoracle/types/msgs.go index 15738a3f0b..056d5310e7 100644 --- a/x/icqoracle/types/msgs.go +++ b/x/icqoracle/types/msgs.go @@ -2,7 +2,6 @@ package types import ( "errors" - "strconv" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" @@ -34,7 +33,7 @@ func NewMsgRegisterTokenPriceQuery( quoteDenom string, baseDecimals int64, quoteDecimals int64, - poolId string, + poolId uint64, osmosisBaseDenom string, osmosisQuoteDenom string, ) *MsgRegisterTokenPriceQuery { @@ -90,7 +89,7 @@ func (msg *MsgRegisterTokenPriceQuery) ValidateBasic() error { // MsgRemoveTokenPriceQuery // ---------------------------------------------- -func NewMsgRemoveTokenPriceQuery(admin, baseDenom, quoteDenom, osmosisPoolId string) *MsgRemoveTokenPriceQuery { +func NewMsgRemoveTokenPriceQuery(admin, baseDenom, quoteDenom string, osmosisPoolId uint64) *MsgRemoveTokenPriceQuery { return &MsgRemoveTokenPriceQuery{ Admin: admin, BaseDenom: baseDenom, @@ -130,8 +129,8 @@ func (msg *MsgRemoveTokenPriceQuery) ValidateBasic() error { if msg.QuoteDenom == "" { return errors.New("quote-denom must be specified") } - if _, err := strconv.ParseUint(msg.OsmosisPoolId, 10, 64); err != nil { - return errors.New("osmosis-pool-id must be uint64") + if msg.OsmosisPoolId == 0 { + return errors.New("osmosis-pool-id must be specified") } return nil diff --git a/x/icqoracle/types/query.pb.go b/x/icqoracle/types/query.pb.go index 161da4c09c..a605b5452a 100644 --- a/x/icqoracle/types/query.pb.go +++ b/x/icqoracle/types/query.pb.go @@ -41,7 +41,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QueryTokenPriceRequest struct { BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` QuoteDenom string `protobuf:"bytes,2,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` - PoolId string `protobuf:"bytes,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` } func (m *QueryTokenPriceRequest) Reset() { *m = QueryTokenPriceRequest{} } @@ -91,11 +91,11 @@ func (m *QueryTokenPriceRequest) GetQuoteDenom() string { return "" } -func (m *QueryTokenPriceRequest) GetPoolId() string { +func (m *QueryTokenPriceRequest) GetPoolId() uint64 { if m != nil { return m.PoolId } - return "" + return 0 } // QueryTokenPriceResponse is the response type for the Query/TokenPrice RPC @@ -438,7 +438,7 @@ type TokenPriceResponse struct { // Quote denom on Osmosis OsmosisQuoteDenom string `protobuf:"bytes,8,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,9,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + OsmosisPoolId uint64 `protobuf:"varint,9,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` // Spot price of base_denom denominated in quote_denom SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,10,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price"` // Last time a query request was submitted @@ -538,11 +538,11 @@ func (m *TokenPriceResponse) GetOsmosisQuoteDenom() string { return "" } -func (m *TokenPriceResponse) GetOsmosisPoolId() string { +func (m *TokenPriceResponse) GetOsmosisPoolId() uint64 { if m != nil { return m.OsmosisPoolId } - return "" + return 0 } func (m *TokenPriceResponse) GetLastRequestTime() time.Time { @@ -581,64 +581,64 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/query.proto", fileDescriptor_51a2bacbcf1e1cb4) } var fileDescriptor_51a2bacbcf1e1cb4 = []byte{ - // 902 bytes of a gzipped FileDescriptorProto + // 906 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcb, 0x6e, 0xdb, 0x46, 0x14, 0x35, 0xfd, 0x50, 0xac, 0xab, 0x04, 0xb6, 0xc7, 0x6e, 0xcd, 0xaa, 0x89, 0x24, 0x30, 0x8e, - 0xeb, 0x1a, 0xcd, 0xb0, 0x71, 0x90, 0x7c, 0x80, 0x60, 0xa4, 0x08, 0x1a, 0x03, 0x0a, 0x9b, 0x6e, - 0xba, 0x11, 0x46, 0xe4, 0x84, 0x21, 0x2c, 0x72, 0x28, 0xce, 0x28, 0xa9, 0xb7, 0x59, 0x74, 0x1d, + 0xab, 0x1a, 0xcd, 0xb0, 0x71, 0x90, 0x7c, 0x80, 0x60, 0xa4, 0x08, 0x1a, 0x03, 0x0a, 0x9b, 0x6e, + 0xba, 0x11, 0x46, 0xe2, 0x84, 0x21, 0x2c, 0x72, 0x28, 0xce, 0x28, 0xa9, 0xb7, 0x59, 0x74, 0x1d, 0xa0, 0x1f, 0x52, 0xa0, 0xab, 0x2e, 0xbb, 0xcc, 0x32, 0x40, 0x37, 0x45, 0x17, 0x69, 0x61, 0xf7, - 0x43, 0x8a, 0x79, 0xf0, 0xa1, 0xd0, 0xae, 0x6c, 0x20, 0x2b, 0x4b, 0xf7, 0x79, 0xce, 0xbd, 0x77, - 0x8e, 0x0c, 0x37, 0xb9, 0xc8, 0xa2, 0x80, 0xba, 0x91, 0x3f, 0x61, 0x19, 0xf1, 0xc7, 0xd4, 0x9d, - 0x4c, 0x69, 0x76, 0x82, 0xd3, 0x8c, 0x09, 0x86, 0xd6, 0xb5, 0x17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xb3, 0xce, 0xc2, 0xbb, 0xb3, 0xce, 0xc2, 0x9f, 0x67, 0x9d, 0x85, 0x1f, 0xee, 0x57, 0x64, - 0xf4, 0x3b, 0x55, 0xe2, 0xee, 0x13, 0x32, 0xe2, 0x79, 0xb9, 0x97, 0x07, 0x0f, 0xdc, 0x1f, 0x2b, - 0x45, 0x95, 0xae, 0x8e, 0x1a, 0xea, 0xda, 0xef, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0x57, 0xeb, - 0xa3, 0x7d, 0x55, 0x09, 0x00, 0x00, + 0x43, 0x8a, 0x79, 0xf0, 0xa1, 0x50, 0xae, 0x6c, 0x20, 0x2b, 0x4b, 0xf7, 0x79, 0xce, 0xbd, 0x77, + 0x8e, 0x0c, 0x37, 0xb9, 0x48, 0x43, 0x9f, 0xba, 0xe1, 0x68, 0xc2, 0x52, 0x32, 0x1a, 0x53, 0x77, + 0x32, 0xa5, 0xe9, 0x29, 0x4e, 0x52, 0x26, 0x18, 0xda, 0xd4, 0x5e, 0x9c, 0x7b, 0x9b, 0x07, 0x23, + 0xc6, 0x23, 0xc6, 0xdd, 0x21, 0xe1, 0x26, 0xd4, 0x7d, 0x79, 0x6f, 0x48, 0x05, 0xb9, 0xe7, 0x26, + 0x24, 0x08, 0x63, 0x22, 0x42, 0x16, 0xeb, 0xec, 0xe6, 0x4e, 0xc0, 0x02, 0xa6, 0x3e, 0xba, 0xf2, + 0x93, 0xb1, 0xde, 0x0c, 0x18, 0x0b, 0xc6, 0xd4, 0x25, 0x49, 0xe8, 0x92, 0x38, 0x66, 0x42, 0xa5, + 0x70, 0xe3, 0x6d, 0x1b, 0xaf, 0xfa, 0x36, 0x9c, 0x3e, 0x77, 0x45, 0x18, 0x51, 0x2e, 0x48, 0x94, + 0x98, 0x80, 0x4e, 0x05, 0x70, 0xfe, 0x49, 0x47, 0x38, 0x13, 0xf8, 0xf4, 0xa9, 0x04, 0xf6, 0x8c, + 0x9d, 0xd0, 0xb8, 0x9f, 0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 0x6b, 0x41, 0x3f, 0x59, 0xd0, 0x28, 0x69, 0x26, 0x5a, 0x5c, + 0x3b, 0x13, 0xaa, 0xe6, 0xc1, 0x65, 0x42, 0x0d, 0x8e, 0x8e, 0xc2, 0xd1, 0x44, 0xf6, 0x05, 0x38, + 0x38, 0x7a, 0x05, 0x35, 0xad, 0x5f, 0x68, 0xef, 0x82, 0xba, 0x33, 0x32, 0xd9, 0xbc, 0xb3, 0x20, + 0xea, 0x12, 0x8d, 0x75, 0xbb, 0x5f, 0x2c, 0xd8, 0xbd, 0x40, 0xb5, 0xd0, 0x83, 0x85, 0x14, 0xe7, + 0x89, 0x69, 0xf3, 0xe1, 0x55, 0xd3, 0x0c, 0xd8, 0x3b, 0x0a, 0x6c, 0x1b, 0xdd, 0x72, 0xe7, 0xfc, + 0x7f, 0x23, 0x5f, 0xa6, 0x9a, 0x55, 0xef, 0xf8, 0xed, 0x59, 0xcb, 0x7a, 0x77, 0xd6, 0xb2, 0xfe, + 0x39, 0x6b, 0x59, 0x6f, 0xce, 0x5b, 0x4b, 0xef, 0xce, 0x5b, 0x4b, 0x7f, 0x9e, 0xb7, 0x96, 0x7e, + 0xb8, 0x5f, 0x92, 0xd1, 0xef, 0x54, 0x89, 0xbb, 0x4f, 0xc8, 0x90, 0x67, 0xe5, 0x5e, 0x1e, 0x3e, + 0x70, 0x7f, 0x2c, 0x15, 0x55, 0xba, 0x3a, 0xac, 0xa9, 0x6b, 0xbf, 0xff, 0x5f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x2d, 0x74, 0x16, 0x15, 0x55, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -857,12 +857,10 @@ func (m *QueryTokenPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if len(m.PoolId) > 0 { - i -= len(m.PoolId) - copy(dAtA[i:], m.PoolId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.PoolId))) + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) @@ -1180,12 +1178,10 @@ func (m *TokenPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x52 - if len(m.OsmosisPoolId) > 0 { - i -= len(m.OsmosisPoolId) - copy(dAtA[i:], m.OsmosisPoolId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.OsmosisPoolId))) + if m.OsmosisPoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.OsmosisPoolId)) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x48 } if len(m.OsmosisQuoteDenom) > 0 { i -= len(m.OsmosisQuoteDenom) @@ -1267,9 +1263,8 @@ func (m *QueryTokenPriceRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.PoolId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) } return n } @@ -1401,9 +1396,8 @@ func (m *TokenPriceResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.OsmosisPoolId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.OsmosisPoolId != 0 { + n += 1 + sovQuery(uint64(m.OsmosisPoolId)) } l = m.SpotPrice.Size() n += 1 + l + sovQuery(uint64(l)) @@ -1517,10 +1511,10 @@ func (m *QueryTokenPriceRequest) Unmarshal(dAtA []byte) error { m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) } - var stringLen uint64 + m.PoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1530,24 +1524,11 @@ func (m *QueryTokenPriceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.PoolId |= 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.PoolId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2449,10 +2430,10 @@ func (m *TokenPriceResponse) Unmarshal(dAtA []byte) error { m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 9: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } - var stringLen uint64 + m.OsmosisPoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2462,24 +2443,11 @@ func (m *TokenPriceResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.OsmosisPoolId |= 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.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SpotPrice", wireType) diff --git a/x/icqoracle/types/tx.pb.go b/x/icqoracle/types/tx.pb.go index e16cfa869c..53ae5b9138 100644 --- a/x/icqoracle/types/tx.pb.go +++ b/x/icqoracle/types/tx.pb.go @@ -47,7 +47,7 @@ type MsgRegisterTokenPriceQuery struct { // Quote denom on Osmosis OsmosisQuoteDenom string `protobuf:"bytes,7,opt,name=osmosis_quote_denom,json=osmosisQuoteDenom,proto3" json:"osmosis_quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,8,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + OsmosisPoolId uint64 `protobuf:"varint,8,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } func (m *MsgRegisterTokenPriceQuery) Reset() { *m = MsgRegisterTokenPriceQuery{} } @@ -132,11 +132,11 @@ func (m *MsgRegisterTokenPriceQuery) GetOsmosisQuoteDenom() string { return "" } -func (m *MsgRegisterTokenPriceQuery) GetOsmosisPoolId() string { +func (m *MsgRegisterTokenPriceQuery) GetOsmosisPoolId() uint64 { if m != nil { return m.OsmosisPoolId } - return "" + return 0 } type MsgRegisterTokenPriceQueryResponse struct { @@ -184,7 +184,7 @@ type MsgRemoveTokenPriceQuery struct { // Quote denom on Stride QuoteDenom string `protobuf:"bytes,3,opt,name=quote_denom,json=quoteDenom,proto3" json:"quote_denom,omitempty"` // Pool ID on Osmosis - OsmosisPoolId string `protobuf:"bytes,4,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` + OsmosisPoolId uint64 `protobuf:"varint,4,opt,name=osmosis_pool_id,json=osmosisPoolId,proto3" json:"osmosis_pool_id,omitempty"` } func (m *MsgRemoveTokenPriceQuery) Reset() { *m = MsgRemoveTokenPriceQuery{} } @@ -241,11 +241,11 @@ func (m *MsgRemoveTokenPriceQuery) GetQuoteDenom() string { return "" } -func (m *MsgRemoveTokenPriceQuery) GetOsmosisPoolId() string { +func (m *MsgRemoveTokenPriceQuery) GetOsmosisPoolId() uint64 { if m != nil { return m.OsmosisPoolId } - return "" + return 0 } type MsgRemoveTokenPriceQueryResponse struct { @@ -294,39 +294,39 @@ func init() { func init() { proto.RegisterFile("stride/icqoracle/tx.proto", fileDescriptor_be640eb75c1babd5) } var fileDescriptor_be640eb75c1babd5 = []byte{ - // 505 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0xb1, 0x6e, 0xd3, 0x50, - 0x14, 0x8d, 0x9b, 0xa6, 0xd0, 0x8b, 0x10, 0xcd, 0x6b, 0x51, 0x5d, 0x4b, 0x98, 0xc8, 0xaa, 0x50, - 0x15, 0xb5, 0x7e, 0x34, 0x81, 0x85, 0x8d, 0xa8, 0x0b, 0x12, 0x91, 0x5a, 0x97, 0x89, 0xc5, 0x72, - 0xec, 0x27, 0xf3, 0x44, 0xec, 0x97, 0xfa, 0x3a, 0xa1, 0x1d, 0x90, 0x10, 0x62, 0x62, 0xe2, 0x37, - 0xd8, 0x32, 0xf0, 0x11, 0x8c, 0x15, 0x13, 0x23, 0x4a, 0x84, 0xf2, 0x1b, 0x28, 0xcf, 0x76, 0x1c, - 0x22, 0x5b, 0x82, 0xa9, 0x8b, 0xad, 0x77, 0xcf, 0xb9, 0xc7, 0xc7, 0xe7, 0xda, 0x17, 0xf6, 0x30, - 0x8e, 0xb8, 0xc7, 0x28, 0x77, 0x2f, 0x44, 0xe4, 0xb8, 0x7d, 0x46, 0xe3, 0x4b, 0x73, 0x10, 0x89, - 0x58, 0x90, 0xad, 0x04, 0x32, 0x17, 0x90, 0x56, 0x77, 0x02, 0x1e, 0x0a, 0x2a, 0xaf, 0x09, 0x49, - 0xdb, 0x73, 0x05, 0x06, 0x02, 0x6d, 0x79, 0xa2, 0xc9, 0x21, 0x85, 0x76, 0x93, 0x13, 0x0d, 0xd0, - 0xa7, 0xa3, 0xe3, 0xf9, 0x2d, 0x01, 0x8c, 0xaf, 0x55, 0xd0, 0xba, 0xe8, 0x5b, 0xcc, 0xe7, 0x18, - 0xb3, 0xe8, 0x95, 0x78, 0xcb, 0xc2, 0xd3, 0x88, 0xbb, 0xec, 0x6c, 0xc8, 0xa2, 0x2b, 0x62, 0x42, - 0xcd, 0xf1, 0x02, 0x1e, 0xaa, 0x4a,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f5, 0xa2, 0x3c, - 0x8e, 0xff, 0xce, 0xc3, 0x58, 0xc9, 0xa3, 0xe0, 0x55, 0x0c, 0x03, 0x1a, 0x65, 0x58, 0x96, 0x45, - 0xeb, 0xd3, 0x1a, 0x54, 0xbb, 0xe8, 0x93, 0xf7, 0xb0, 0x5b, 0xf6, 0x85, 0x1f, 0x9a, 0xab, 0xbf, - 0x96, 0x59, 0x1e, 0xb2, 0xf6, 0xe4, 0x7f, 0xd8, 0x99, 0x0d, 0xf2, 0x0e, 0xee, 0x17, 0x8f, 0xa3, - 0x59, 0x22, 0x57, 0xc0, 0xd5, 0x5a, 0xff, 0xce, 0xcd, 0x1e, 0xac, 0xd5, 0x3e, 0xcc, 0xc6, 0x4d, - 0xa5, 0xd3, 0xfd, 0x3e, 0xd1, 0x95, 0xeb, 0x89, 0xae, 0xfc, 0x9a, 0xe8, 0xca, 0x97, 0xa9, 0x5e, - 0xb9, 0x9e, 0xea, 0x95, 0x9f, 0x53, 0xbd, 0xf2, 0xba, 0xed, 0xf3, 0xf8, 0xcd, 0xb0, 0x67, 0xba, - 0x22, 0xa0, 0xe7, 0x52, 0xfe, 0xe8, 0xa5, 0xd3, 0x43, 0x9a, 0x6e, 0xa2, 0x51, 0xeb, 0x29, 0xbd, - 0x5c, 0xde, 0x47, 0x57, 0x03, 0x86, 0xbd, 0x0d, 0xb9, 0x3a, 0xda, 0x7f, 0x02, 0x00, 0x00, 0xff, - 0xff, 0x7b, 0x76, 0x0a, 0x6f, 0xb0, 0x04, 0x00, 0x00, + // 508 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xce, 0x35, 0x49, 0xa1, 0x0f, 0x21, 0x9a, 0x6b, 0x51, 0x5d, 0x4b, 0x98, 0xc8, 0xaa, 0x50, + 0x14, 0xb5, 0x3e, 0x9a, 0xc0, 0xc2,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1a, 0xeb, 0xbf, 0x96, 0x51, 0x1e, 0xb2, 0xfa, 0xe4, 0x7f, 0xd8, 0xa9, 0x0d, 0xfc, 0x0e, 0xee, + 0x17, 0x8f, 0xa3, 0x5d, 0x22, 0x57, 0xc0, 0x55, 0x3b, 0xff, 0xce, 0x4d, 0x1f, 0xac, 0xd6, 0x3f, + 0x2c, 0xa6, 0x6d, 0xd4, 0xeb, 0x7f, 0x9f, 0x69, 0xe8, 0x7a, 0xa6, 0xa1, 0x5f, 0x33, 0x0d, 0x7d, + 0x99, 0x6b, 0x95, 0xeb, 0xb9, 0x56, 0xf9, 0x39, 0xd7, 0x2a, 0xaf, 0xbb, 0x1e, 0x8b, 0xde, 0x8c, + 0x07, 0x86, 0xc3, 0x7d, 0x72, 0x2e, 0xe5, 0x8f, 0x5e, 0xda, 0x03, 0x41, 0x92, 0x4d, 0x34, 0xe9, + 0x3c, 0x25, 0x97, 0xf9, 0x7d, 0x74, 0x35, 0xa2, 0x62, 0xb0, 0x29, 0x57, 0x47, 0xf7, 0x4f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xd0, 0x5a, 0x62, 0x60, 0xb0, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -469,12 +469,10 @@ func (m *MsgRegisterTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if len(m.OsmosisPoolId) > 0 { - i -= len(m.OsmosisPoolId) - copy(dAtA[i:], m.OsmosisPoolId) - i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisPoolId))) + if m.OsmosisPoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OsmosisPoolId)) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x40 } if len(m.OsmosisQuoteDenom) > 0 { i -= len(m.OsmosisQuoteDenom) @@ -567,12 +565,10 @@ func (m *MsgRemoveTokenPriceQuery) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l - if len(m.OsmosisPoolId) > 0 { - i -= len(m.OsmosisPoolId) - copy(dAtA[i:], m.OsmosisPoolId) - i = encodeVarintTx(dAtA, i, uint64(len(m.OsmosisPoolId))) + if m.OsmosisPoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OsmosisPoolId)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x20 } if len(m.QuoteDenom) > 0 { i -= len(m.QuoteDenom) @@ -664,9 +660,8 @@ func (m *MsgRegisterTokenPriceQuery) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.OsmosisPoolId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.OsmosisPoolId != 0 { + n += 1 + sovTx(uint64(m.OsmosisPoolId)) } return n } @@ -698,9 +693,8 @@ func (m *MsgRemoveTokenPriceQuery) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.OsmosisPoolId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.OsmosisPoolId != 0 { + n += 1 + sovTx(uint64(m.OsmosisPoolId)) } return n } @@ -948,10 +942,10 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { m.OsmosisQuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 8: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } - var stringLen uint64 + m.OsmosisPoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -961,24 +955,11 @@ func (m *MsgRegisterTokenPriceQuery) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.OsmosisPoolId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1176,10 +1157,10 @@ func (m *MsgRemoveTokenPriceQuery) Unmarshal(dAtA []byte) error { m.QuoteDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field OsmosisPoolId", wireType) } - var stringLen uint64 + m.OsmosisPoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1189,24 +1170,11 @@ func (m *MsgRemoveTokenPriceQuery) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.OsmosisPoolId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OsmosisPoolId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/icqoracle/types/validate.go b/x/icqoracle/types/validate.go index e0bc68d252..404faa8353 100644 --- a/x/icqoracle/types/validate.go +++ b/x/icqoracle/types/validate.go @@ -2,7 +2,6 @@ package types import ( "errors" - "strconv" ) func ValidateTokenPriceQueryParams( @@ -10,7 +9,7 @@ func ValidateTokenPriceQueryParams( quoteDenom string, baseDenomDecimals int64, quoteDenomDecimals int64, - osmosisPoolId string, + osmosisPoolId uint64, osmosisBaseDenom string, osmosisQuoteDenom string, ) error { @@ -26,8 +25,8 @@ func ValidateTokenPriceQueryParams( if quoteDenomDecimals <= 0 { return errors.New("quote-denom-decimals must be bigger than 0") } - if _, err := strconv.ParseUint(osmosisPoolId, 10, 64); err != nil { - return errors.New("osmosis-pool-id must be uint64") + if osmosisPoolId == 0 { + return errors.New("osmosis-pool-id must be specified") } if osmosisBaseDenom == "" { return errors.New("osmosis-base-denom must be specified") From 4967288205fed3682656aff18264498e3446f908 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Feb 2025 15:45:00 -0600 Subject: [PATCH 114/115] updated keepers to get/set directly (#1349) --- app/upgrades/v26/upgrades.go | 7 +- app/upgrades/v26/upgrades_test.go | 3 +- x/auction/keeper/auction.go | 71 ++++++ x/auction/keeper/auction_test.go | 58 +++++ x/auction/keeper/genesis.go | 15 +- .../keeper/{auction_type.go => handlers.go} | 5 +- x/auction/keeper/keeper.go | 76 ------ x/auction/keeper/keeper_test.go | 5 - x/auction/keeper/msg_server.go | 12 +- x/auction/keeper/msg_server_test.go | 73 +++--- x/auction/keeper/params.go | 19 +- x/auction/keeper/params_test.go | 6 +- x/auction/keeper/query_test.go | 6 +- x/icqoracle/keeper/abci.go | 8 +- x/icqoracle/keeper/abci_test.go | 17 +- x/icqoracle/keeper/genesis.go | 15 +- x/icqoracle/keeper/icq.go | 11 +- x/icqoracle/keeper/icq_test.go | 83 +++---- x/icqoracle/keeper/keeper.go | 229 ------------------ x/icqoracle/keeper/keeper_test.go | 14 +- x/icqoracle/keeper/msg_server.go | 6 +- x/icqoracle/keeper/msg_server_test.go | 5 +- x/icqoracle/keeper/params.go | 19 +- x/icqoracle/keeper/params_test.go | 6 +- x/icqoracle/keeper/query.go | 5 +- x/icqoracle/keeper/query_test.go | 133 +++------- x/icqoracle/keeper/token_price.go | 216 +++++++++++++++++ x/icqoracle/keeper/token_price_test.go | 51 ++++ x/icqoracle/types/keys.go | 2 +- 29 files changed, 534 insertions(+), 642 deletions(-) create mode 100644 x/auction/keeper/auction.go create mode 100644 x/auction/keeper/auction_test.go rename x/auction/keeper/{auction_type.go => handlers.go} (97%) create mode 100644 x/icqoracle/keeper/token_price.go create mode 100644 x/icqoracle/keeper/token_price_test.go diff --git a/app/upgrades/v26/upgrades.go b/app/upgrades/v26/upgrades.go index 632c8d4117..e15df41573 100644 --- a/app/upgrades/v26/upgrades.go +++ b/app/upgrades/v26/upgrades.go @@ -1,8 +1,6 @@ package v26 import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -30,15 +28,12 @@ func CreateUpgradeHandler( return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { ctx.Logger().Info("Starting upgrade v26...") - err := icqoracleKeeper.SetParams(ctx, icqoracletypes.Params{ + icqoracleKeeper.SetParams(ctx, icqoracletypes.Params{ OsmosisChainId: OsmosisChainId, OsmosisConnectionId: OsmosisConnectionId, UpdateIntervalSec: ICQOracleUpdateIntervalSec, PriceExpirationTimeoutSec: ICQOraclePriceExpirationTimeoutSec, }) - if err != nil { - panic(fmt.Errorf("unable to set icqoracle params: %w", err)) - } ctx.Logger().Info("Running module migrations...") return mm.RunMigrations(ctx, configurator, vm) diff --git a/app/upgrades/v26/upgrades_test.go b/app/upgrades/v26/upgrades_test.go index aa9ee632f0..4258e8198b 100644 --- a/app/upgrades/v26/upgrades_test.go +++ b/app/upgrades/v26/upgrades_test.go @@ -26,8 +26,7 @@ func (s *UpgradeTestSuite) TestUpgrade() { s.ConfirmUpgradeSucceededs(v26.UpgradeName, upgradeHeight) - params, err := s.App.ICQOracleKeeper.GetParams(s.Ctx) - s.Require().NoError(err, "No error expected when getting params") + params := s.App.ICQOracleKeeper.GetParams(s.Ctx) s.Require().Equal(v26.OsmosisChainId, params.OsmosisChainId, "Osmosis chain ID") s.Require().Equal(v26.OsmosisConnectionId, params.OsmosisConnectionId, "Osmosis connection ID") s.Require().Equal(v26.ICQOracleUpdateIntervalSec, params.UpdateIntervalSec, "Update interval") diff --git a/x/auction/keeper/auction.go b/x/auction/keeper/auction.go new file mode 100644 index 0000000000..00663b256c --- /dev/null +++ b/x/auction/keeper/auction.go @@ -0,0 +1,71 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/store/prefix" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v25/x/auction/types" +) + +// SetAuction stores auction info for a token +func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) + key := []byte(auction.Name) + bz := k.cdc.MustMarshal(auction) + store.Set(key, bz) +} + +// GetAuction retrieves auction info for a token +func (k Keeper) GetAuction(ctx sdk.Context, name string) (*types.Auction, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) + key := []byte(name) + + bz := store.Get(key) + if bz == nil { + return &types.Auction{}, fmt.Errorf("auction not found for denom '%s'", name) + } + + var auction types.Auction + if err := k.cdc.Unmarshal(bz, &auction); err != nil { + return &types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.SellingDenom, err) + } + + return &auction, nil +} + +// GetAllAuctions retrieves all stored auctions +func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) + iterator := store.Iterator(nil, nil) + defer iterator.Close() + + auctions := []types.Auction{} + for ; iterator.Valid(); iterator.Next() { + var auction types.Auction + k.cdc.MustUnmarshal(iterator.Value(), &auction) + auctions = append(auctions, auction) + } + + return auctions +} + +// PlaceBid places an auction bid and executes it based on the auction type +func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { + // Get auction + auction, err := k.GetAuction(ctx, bid.AuctionName) + if err != nil { + return fmt.Errorf("cannot get auction for name='%s': %w", bid.AuctionName, err) + } + + // Get the appropriate auctionBidHandler for the auction type + auctionBidHandler, exists := bidHandlers[auction.Type] + if !exists { + return fmt.Errorf("unsupported auction type: %s", auction.Type) + } + + // Call the handler + return auctionBidHandler(ctx, k, auction, bid) +} diff --git a/x/auction/keeper/auction_test.go b/x/auction/keeper/auction_test.go new file mode 100644 index 0000000000..39c78e87ef --- /dev/null +++ b/x/auction/keeper/auction_test.go @@ -0,0 +1,58 @@ +package keeper_test + +import ( + "fmt" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v25/x/auction/types" +) + +// Helper function to create 5 auction objects with various attributes +func (s *KeeperTestSuite) createAuctions() []types.Auction { + auctions := []types.Auction{} + for i := int64(1); i <= 5; i++ { + auction := types.Auction{ + Type: types.AuctionType_AUCTION_TYPE_FCFS, + Name: fmt.Sprintf("auction-%d", i), + SellingDenom: fmt.Sprintf("selling-%d", i), + PaymentDenom: fmt.Sprintf("payment-%d", i), + Enabled: true, + MinPriceMultiplier: sdk.ZeroDec(), + MinBidAmount: sdkmath.NewInt(i), + TotalPaymentTokenReceived: sdkmath.NewInt(i), + TotalSellingTokenSold: sdkmath.NewInt(i), + } + + auctions = append(auctions, auction) + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) + } + return auctions +} + +// Tests Get/Set Auction +func (s *KeeperTestSuite) TestGetAuction() { + auctions := s.createAuctions() + + for _, expected := range auctions { + actual, err := s.App.AuctionKeeper.GetAuction(s.Ctx, expected.Name) + s.Require().NoError(err, "auction %s should have been found", expected.Name) + s.Require().Equal(expected, *actual, "auction %s", expected.Name) + } + + _, err := s.App.AuctionKeeper.GetAuction(s.Ctx, "non-existent") + s.Require().ErrorContains(err, "auction not found") +} + +// Tests getting all auctions +func (s *KeeperTestSuite) TestGetAllAuctions() { + expectedAuctions := s.createAuctions() + + actualAuctions := s.App.AuctionKeeper.GetAllAuctions(s.Ctx) + s.Require().Equal(len(actualAuctions), len(expectedAuctions), "number of auctions") + + for i, expectedAuction := range expectedAuctions { + s.Require().Equal(expectedAuction, actualAuctions[i], "auction %s", expectedAuction.Name) + } +} diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 13394fff2c..f3debfc26d 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -8,25 +8,16 @@ import ( // Loads module state from genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - err := k.SetParams(ctx, genState.Params) - if err != nil { - panic(err) - } + k.SetParams(ctx, genState.Params) for _, auction := range genState.Auctions { - if err := k.SetAuction(ctx, &auction); err != nil { - panic(err) - } + k.SetAuction(ctx, &auction) } } // Export's module state into genesis file func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - params, err := k.GetParams(ctx) - if err != nil { - panic(err) - } - + params := k.GetParams(ctx) genesis := types.DefaultGenesis() genesis.Params = params genesis.Auctions = k.GetAllAuctions(ctx) diff --git a/x/auction/keeper/auction_type.go b/x/auction/keeper/handlers.go similarity index 97% rename from x/auction/keeper/auction_type.go rename to x/auction/keeper/handlers.go index a4a795dc17..8f2e11299e 100644 --- a/x/auction/keeper/auction_type.go +++ b/x/auction/keeper/handlers.go @@ -96,10 +96,7 @@ func fcfsBidHandler(ctx sdk.Context, k Keeper, auction *types.Auction, bid *type auction.TotalSellingTokenSold = auction.TotalSellingTokenSold.Add(bid.SellingTokenAmount) auction.TotalPaymentTokenReceived = auction.TotalPaymentTokenReceived.Add(bid.PaymentTokenAmount) - err = k.SetAuction(ctx, auction) - if err != nil { - return errorsmod.Wrap(err, "failed to update auction stats") - } + k.SetAuction(ctx, auction) ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index d76b47de08..c669515ed7 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -1,13 +1,8 @@ package keeper import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/store/prefix" - "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Stride-Labs/stride/v25/x/auction/types" ) @@ -35,74 +30,3 @@ func NewKeeper( icqoracleKeeper: icqoracleKeeper, } } - -// SetAuction stores auction info for a token -func (k Keeper) SetAuction(ctx sdk.Context, auction *types.Auction) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) - key := []byte(auction.Name) - - bz, err := k.cdc.Marshal(auction) - if err != nil { - return fmt.Errorf("error setting auction for name='%s': %w", auction.Name, err) - } - - store.Set(key, bz) - return nil -} - -// GetAuction retrieves auction info for a token -func (k Keeper) GetAuction(ctx sdk.Context, name string) (*types.Auction, error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) - key := []byte(name) - - bz := store.Get(key) - if bz == nil { - return &types.Auction{}, fmt.Errorf("auction not found for denom '%s'", name) - } - - var auction types.Auction - if err := k.cdc.Unmarshal(bz, &auction); err != nil { - return &types.Auction{}, fmt.Errorf("error retrieving auction for denom '%s': %w", auction.SellingDenom, err) - } - - return &auction, nil -} - -// GetAllAuctions retrieves all stored auctions -func (k Keeper) GetAllAuctions(ctx sdk.Context) []types.Auction { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionPrefix) - iterator := store.Iterator(nil, nil) - defer iterator.Close() - - auctions := []types.Auction{} - for ; iterator.Valid(); iterator.Next() { - var auction types.Auction - k.cdc.MustUnmarshal(iterator.Value(), &auction) - auctions = append(auctions, auction) - } - - return auctions -} - -// PlaceBid places an auction bid and executes it based on the auction type -func (k Keeper) PlaceBid(ctx sdk.Context, bid *types.MsgPlaceBid) error { - // Get auction - auction, err := k.GetAuction(ctx, bid.AuctionName) - if err != nil { - return fmt.Errorf("cannot get auction for name='%s': %w", bid.AuctionName, err) - } - - // Get the appropriate auctionBidHandler for the auction type - auctionBidHandler, exists := bidHandlers[auction.Type] - if !exists { - return fmt.Errorf("unsupported auction type: %s", auction.Type) - } - - // Call the handler - return auctionBidHandler(ctx, k, auction, bid) -} - -// GetStoreKey returns the store key -func (k Keeper) GetStoreKey() storetypes.StoreKey { - return k.storeKey -} diff --git a/x/auction/keeper/keeper_test.go b/x/auction/keeper/keeper_test.go index 3e285c0eb7..777c74b2b6 100644 --- a/x/auction/keeper/keeper_test.go +++ b/x/auction/keeper/keeper_test.go @@ -45,8 +45,3 @@ func (s *KeeperTestSuite) MustGetAuction(name string) types.Auction { s.Require().NoError(err, "no error expected when getting auction") return *auction } - -func (s *KeeperTestSuite) DeleteParams() { - store := s.Ctx.KVStore(s.App.AuctionKeeper.GetStoreKey()) - store.Delete([]byte(types.ParamsKey)) -} diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 0877b81019..fe889da21d 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -54,11 +54,7 @@ func (ms msgServer) CreateAuction(goCtx context.Context, msg *types.MsgCreateAuc TotalPaymentTokenReceived: math.ZeroInt(), TotalSellingTokenSold: math.ZeroInt(), } - - err = ms.Keeper.SetAuction(ctx, &auction) - if err != nil { - return nil, err - } + ms.Keeper.SetAuction(ctx, &auction) return &types.MsgCreateAuctionResponse{}, nil } @@ -77,11 +73,7 @@ func (ms msgServer) UpdateAuction(goCtx context.Context, msg *types.MsgUpdateAuc auction.MinBidAmount = msg.MinBidAmount auction.MinPriceMultiplier = msg.MinPriceMultiplier auction.Beneficiary = msg.Beneficiary - - err = ms.Keeper.SetAuction(ctx, auction) - if err != nil { - return nil, err - } + ms.Keeper.SetAuction(ctx, auction) return &types.MsgUpdateAuctionResponse{}, nil } diff --git a/x/auction/keeper/msg_server_test.go b/x/auction/keeper/msg_server_test.go index 243bcb19da..f0dd3de897 100644 --- a/x/auction/keeper/msg_server_test.go +++ b/x/auction/keeper/msg_server_test.go @@ -56,8 +56,7 @@ func (s *KeeperTestSuite) TestUpdateAuction() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: "beneficiary-address", } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Update the auction msg := types.MsgUpdateAuction{ @@ -68,7 +67,7 @@ func (s *KeeperTestSuite) TestUpdateAuction() { MinBidAmount: sdkmath.NewInt(2000), Beneficiary: "new-beneficiary-address", } - _, err = s.GetMsgServer().UpdateAuction(sdk.UnwrapSDKContext(s.Ctx), &msg) + _, err := s.GetMsgServer().UpdateAuction(sdk.UnwrapSDKContext(s.Ctx), &msg) s.Require().NoError(err, "no error expected when updating auction") // Confirm the auction was updated @@ -97,8 +96,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidHappyPath() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Create a price tokenPrice := icqoracletypes.TokenPrice{ @@ -109,8 +107,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidHappyPath() { LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting tokenPrice") + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Prepare bid bidder := s.TestAccs[0] @@ -128,7 +125,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidHappyPath() { s.FundAccount(bidder, sdk.NewCoin(auction.PaymentDenom, msg.PaymentTokenAmount)) // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) s.Require().NoError(err, "no error expected when placing bid") // Check payment token to beneficiary @@ -178,8 +175,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidUnsupportedAuctionType() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Prepare bid bidder := s.TestAccs[0] @@ -191,9 +187,8 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidUnsupportedAuctionType() { } // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid") - s.Require().Contains(err.Error(), "unsupported auction type") + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorContains(err, "unsupported auction type") } func (s *KeeperTestSuite) TestFcfsPlaceBidAuctionNoFound() { @@ -208,8 +203,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidAuctionNoFound() { // Place Bid _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid") - s.Require().Contains(err.Error(), "cannot get auction for name='banana'") + s.Require().ErrorContains(err, "cannot get auction for name='banana'") } func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughSellingTokens() { @@ -224,8 +218,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughSellingTokens() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Prepare bid bidder := s.TestAccs[0] @@ -237,9 +230,8 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughSellingTokens() { } // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid") - s.Require().Contains(err.Error(), "bid wants to buy 1000uosmo but auction only has 0uosmo") + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorContains(err, "bid wants to buy 1000uosmo but auction only has 0uosmo") } func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForSellingDenom() { @@ -254,8 +246,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForSellingDenom() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Prepare bid bidder := s.TestAccs[0] @@ -270,9 +261,8 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForSellingDenom() { s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid") - s.Require().Contains(err.Error(), "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for baseDenom 'uosmo'") + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorContains(err, "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for baseDenom 'uosmo'") } func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { @@ -287,8 +277,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Create a price only for SellingDenom tokenPrice := icqoracletypes.TokenPrice{ @@ -299,8 +288,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting tokenPrice") + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Prepare bid bidder := s.TestAccs[0] @@ -315,9 +303,8 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNoPriceForPaymentDenom() { s.FundModuleAccount(types.ModuleName, sdk.NewCoin(auction.SellingDenom, msg.SellingTokenAmount)) // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid") - s.Require().Contains(err.Error(), "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for quoteDenom 'ustrd'") + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorContains(err, "error getting price for baseDenom='uosmo' quoteDenom='ustrd': no price for quoteDenom 'ustrd'") } func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { @@ -332,8 +319,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: "beneficiary-address", } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Create a price tokenPrice := icqoracletypes.TokenPrice{ @@ -344,8 +330,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting tokenPrice") + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Prepare bid with a price that's too low // With spot price = 1 and multiplier = 1, minimum accepted price should be 1 @@ -366,9 +351,8 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidTooLowPrice() { s.FundAccount(bidder, sdk.NewCoin(auction.PaymentDenom, msg.PaymentTokenAmount)) // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid with price too low") - s.Require().Contains(err.Error(), "bid price too low") + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorContains(err, "bid price too low") } func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { @@ -383,8 +367,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { MinBidAmount: sdkmath.NewInt(1000), Beneficiary: s.App.StrdBurnerKeeper.GetStrdBurnerAddress().String(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) // Create a price tokenPrice := icqoracletypes.TokenPrice{ @@ -395,8 +378,7 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { LastRequestTime: s.Ctx.BlockTime(), QueryInProgress: false, } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting tokenPrice") + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Prepare bid bidder := s.TestAccs[0] @@ -413,7 +395,6 @@ func (s *KeeperTestSuite) TestFcfsPlaceBidNotEnoughPaymentTokens() { // DON'T fund the bidder with payment tokens // Place Bid - _, err = s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) - s.Require().Error(err, "error expected when placing bid") - s.Require().Contains(err.Error(), "failed to send payment tokens from bidder") + _, err := s.GetMsgServer().PlaceBid(sdk.UnwrapSDKContext(s.Ctx), &msg) + s.Require().ErrorContains(err, "failed to send payment tokens from bidder") } diff --git a/x/auction/keeper/params.go b/x/auction/keeper/params.go index 1b831959cf..5cd2a38329 100644 --- a/x/auction/keeper/params.go +++ b/x/auction/keeper/params.go @@ -7,21 +7,16 @@ import ( ) // GetParams get params -func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { store := ctx.KVStore(k.storeKey) - bz := store.Get([]byte(types.ParamsKey)) - params := types.Params{} - err := k.cdc.UnmarshalJSON(bz, ¶ms) - return params, err + bz := store.Get(types.ParamsKey) + k.cdc.MustUnmarshal(bz, ¶ms) + return params } // SetParams set params -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.MarshalJSON(¶ms) - if err != nil { - return err - } - store.Set([]byte(types.ParamsKey), bz) - return nil + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) } diff --git a/x/auction/keeper/params_test.go b/x/auction/keeper/params_test.go index 5260efa2e4..833f4a350d 100644 --- a/x/auction/keeper/params_test.go +++ b/x/auction/keeper/params_test.go @@ -4,10 +4,8 @@ import "github.com/Stride-Labs/stride/v25/x/auction/types" func (s *KeeperTestSuite) TestParams() { expectedParams := types.Params{} - err := s.App.AuctionKeeper.SetParams(s.Ctx, expectedParams) - s.Require().NoError(err, "should not error on set params") + s.App.AuctionKeeper.SetParams(s.Ctx, expectedParams) - actualParams, err := s.App.AuctionKeeper.GetParams(s.Ctx) - s.Require().NoError(err, "should not error on get params") + actualParams := s.App.AuctionKeeper.GetParams(s.Ctx) s.Require().Equal(expectedParams, actualParams, "params") } diff --git a/x/auction/keeper/query_test.go b/x/auction/keeper/query_test.go index ce7b168773..9fe7f6e6a4 100644 --- a/x/auction/keeper/query_test.go +++ b/x/auction/keeper/query_test.go @@ -21,8 +21,7 @@ func (s *KeeperTestSuite) TestQueryAuction() { TotalSellingTokenSold: sdkmath.ZeroInt(), TotalPaymentTokenReceived: sdkmath.ZeroInt(), } - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &expectedAuction) - s.Require().NoError(err, "no error expected when setting auction") + s.App.AuctionKeeper.SetAuction(s.Ctx, &expectedAuction) // Query for the auction req := &types.QueryAuctionRequest{ @@ -75,8 +74,7 @@ func (s *KeeperTestSuite) TestQueryAuctions() { } for _, auction := range expectedAuctions { - err := s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) - s.Require().NoError(err, "no error expected when setting auction %+v", auction) + s.App.AuctionKeeper.SetAuction(s.Ctx, &auction) } // Query all auctions diff --git a/x/icqoracle/keeper/abci.go b/x/icqoracle/keeper/abci.go index 60fb2e44d1..273f1ed59d 100644 --- a/x/icqoracle/keeper/abci.go +++ b/x/icqoracle/keeper/abci.go @@ -11,11 +11,7 @@ import ( ) func (k Keeper) BeginBlocker(ctx sdk.Context) { - params, err := k.GetParams(ctx) - if err != nil { - ctx.Logger().Error("Unable to fetch params") - return - } + params := k.GetParams(ctx) for _, tokenPrice := range k.GetAllTokenPrices(ctx) { if err := k.RefreshTokenPrice(ctx, tokenPrice, params.UpdateIntervalSec); err != nil { @@ -43,7 +39,7 @@ func (k Keeper) RefreshTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice, // have the same query ID if err := k.SubmitOsmosisClPoolICQ(ctx, tokenPrice); err != nil { return errorsmod.Wrapf(err, - "failed to submit Osmosis CL pool ICQ baseToken='%s' quoteToken='%s' poolId='%s'", + "failed to submit Osmosis CL pool ICQ baseToken='%s' quoteToken='%s' poolId='%d'", tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) diff --git a/x/icqoracle/keeper/abci_test.go b/x/icqoracle/keeper/abci_test.go index a65e7c27e6..491d89b000 100644 --- a/x/icqoracle/keeper/abci_test.go +++ b/x/icqoracle/keeper/abci_test.go @@ -72,16 +72,14 @@ func (s *KeeperTestSuite) TestBeginBlockerSubmitICQ() { s.SetupTest() // Setup params - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Reset mock IcqKeeper s.App.ICQOracleKeeper.IcqKeeper = mockICQKeeper submitICQCalled = false // Store token price - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tc.tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tc.tokenPrice) // Set block time to now s.Ctx = s.Ctx.WithBlockTime(now) @@ -124,11 +122,10 @@ func (s *KeeperTestSuite) TestBeginBlockerICQErrors() { OsmosisPoolId: 1, LastRequestTime: time.Time{}, // Zero time to trigger update } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Run BeginBlocker - should log error but continue - err = s.App.ICQOracleKeeper.RefreshTokenPrice(s.Ctx, tokenPrice, updateIntervalSec) + err := s.App.ICQOracleKeeper.RefreshTokenPrice(s.Ctx, tokenPrice, updateIntervalSec) s.Require().ErrorContains(err, "failed to submit Osmosis CL pool ICQ") // Verify token price query was not submitted @@ -157,8 +154,7 @@ func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { params := types.Params{ UpdateIntervalSec: 60, } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) now := time.Now().UTC() staleTime := now.Add(-2 * time.Minute) @@ -197,8 +193,7 @@ func (s *KeeperTestSuite) TestBeginBlockerMultipleTokens() { // Store all token prices for _, tp := range tokenPrices { - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tp) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tp) } // Set block time diff --git a/x/icqoracle/keeper/genesis.go b/x/icqoracle/keeper/genesis.go index a25bc66baa..5e6025cc0e 100644 --- a/x/icqoracle/keeper/genesis.go +++ b/x/icqoracle/keeper/genesis.go @@ -8,25 +8,16 @@ import ( // Loads module state from genesis func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - err := k.SetParams(ctx, genState.Params) - if err != nil { - panic(err) - } + k.SetParams(ctx, genState.Params) for _, tokenPrice := range genState.TokenPrices { - if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { - panic(err) - } + k.SetTokenPrice(ctx, tokenPrice) } } // Export's module state into genesis file func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - params, err := k.GetParams(ctx) - if err != nil { - panic(err) - } - + params := k.GetParams(ctx) genesis := types.DefaultGenesis() genesis.Params = params genesis.TokenPrices = k.GetAllTokenPrices(ctx) diff --git a/x/icqoracle/keeper/icq.go b/x/icqoracle/keeper/icq.go index 30ac1c2274..9d8d9c2224 100644 --- a/x/icqoracle/keeper/icq.go +++ b/x/icqoracle/keeper/icq.go @@ -60,10 +60,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( ) error { k.Logger(ctx).Info(utils.LogWithTokenPriceQuery(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId, "Submitting OsmosisClPool ICQ")) - params, err := k.GetParams(ctx) - if err != nil { - return errorsmod.Wrap(err, "Error getting module params") - } + params := k.GetParams(ctx) tokenPriceBz, err := k.cdc.Marshal(&tokenPrice) if err != nil { @@ -86,7 +83,7 @@ func (k Keeper) SubmitOsmosisClPoolICQ( return errorsmod.Wrap(err, "Error submitting OsmosisClPool ICQ") } - if err := k.SetTokenPriceQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId); err != nil { + if err := k.SetQueryInProgress(ctx, tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId); err != nil { return errorsmod.Wrap(err, "Error updating token price query to in progress") } @@ -120,9 +117,7 @@ func OsmosisClPoolCallback(k Keeper, ctx sdk.Context, args []byte, query icqtype return errorsmod.Wrap(err, "Error determining spot price from query response") } - if err := k.SetTokenPriceQueryComplete(ctx, tokenPrice, newSpotPrice); err != nil { - return errorsmod.Wrapf(err, "Unable to mark token price query as complete") - } + k.SetQueryComplete(ctx, tokenPrice, newSpotPrice) return nil } diff --git a/x/icqoracle/keeper/icq_test.go b/x/icqoracle/keeper/icq_test.go index ffa34fffde..0817e41ccf 100644 --- a/x/icqoracle/keeper/icq_test.go +++ b/x/icqoracle/keeper/icq_test.go @@ -40,11 +40,10 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQUnknownPrice() { OsmosisConnectionId: "connection-0", UpdateIntervalSec: 60, } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Submit ICQ request - err = s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) + err := s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) s.Require().ErrorContains(err, "price not found") } @@ -67,22 +66,20 @@ func (s *KeeperTestSuite) TestHappyPathOsmosisClPoolICQ() { OsmosisPoolId: 1, } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", UpdateIntervalSec: 60, } - err = s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Verify tokenPrice.QueryInProgress before s.Require().False(tokenPrice.QueryInProgress) // Submit ICQ request - err = s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) + err := s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) s.Require().NoError(err) // Verify the submitted query @@ -113,8 +110,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { OsmosisConnectionId: "connection-0", UpdateIntervalSec: 60, } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Mock ICQ keeper to return error s.mockICQKeeper = MockICQKeeper{ @@ -139,8 +135,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { OsmosisConnectionId: "connection-0", UpdateIntervalSec: 60, } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Setup mock ICQ keeper with success response s.mockICQKeeper = MockICQKeeper{ @@ -169,8 +164,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { OsmosisConnectionId: "connection-0", UpdateIntervalSec: 60, } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Setup mock ICQ keeper with success response s.mockICQKeeper = MockICQKeeper{ @@ -200,8 +194,8 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { // If this is not an error case testing query in progress, // set the token price first if tc.expectedError != "token price not found" { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tc.tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tc.tokenPrice) + } // Execute @@ -209,8 +203,7 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQBranches() { // Verify results if tc.expectedError != "" { - s.Require().Error(err) - s.Require().Contains(err.Error(), tc.expectedError) + s.Require().ErrorContains(err, tc.expectedError) } else { s.Require().NoError(err) @@ -246,19 +239,17 @@ func (s *KeeperTestSuite) TestSubmitOsmosisClPoolICQQueryData() { QuoteDenom: "uusdc", OsmosisPoolId: 1, } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) params := types.Params{ OsmosisChainId: "osmosis-1", OsmosisConnectionId: "connection-0", UpdateIntervalSec: 60, } - err = s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Submit ICQ request - err = s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) + err := s.App.ICQOracleKeeper.SubmitOsmosisClPoolICQ(s.Ctx, tokenPrice) s.Require().NoError(err) // Verify the captured query data @@ -346,8 +337,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { setup: func() ([]byte, icqtypes.Query) { tokenPrice := baseTokenPrice tokenPrice.QueryInProgress = false - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&tokenPrice) s.Require().NoError(err) @@ -364,8 +354,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "invalid pool data", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -379,8 +368,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "successful update with valid pool data", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -415,8 +403,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "successful update with inverse pool data", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -480,8 +467,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "empty pool response data", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -495,8 +481,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "nil pool response data", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -510,8 +495,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "corrupted pool response data", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -527,8 +511,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "pool with empty tokens", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -551,8 +534,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "pool with invalid sqrt price", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -575,8 +557,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { { name: "pool with invalid inverse sqrt price", setup: func() ([]byte, icqtypes.Query) { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -600,8 +581,7 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { name: "error setting updated token price", setup: func() ([]byte, icqtypes.Query) { // First set the token price - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, baseTokenPrice) tokenPriceBz, err := s.App.AppCodec().Marshal(&baseTokenPrice) s.Require().NoError(err) @@ -636,17 +616,11 @@ func (s *KeeperTestSuite) TestOsmosisClPoolCallback() { poolData, query := tc.setup() // Execute callback - err := s.icqCallbacks.CallICQCallback( - s.Ctx, - keeper.ICQCallbackID_OsmosisClPool, - poolData, - query, - ) + err := keeper.OsmosisClPoolCallback(s.App.ICQOracleKeeper, s.Ctx, poolData, query) // Verify results if tc.expectedError != "" { - s.Require().Error(err) - s.Require().Contains(err.Error(), tc.expectedError) + s.Require().ErrorContains(err, tc.expectedError) } else if tc.verify != nil { tc.verify(err) } @@ -762,8 +736,7 @@ func (s *KeeperTestSuite) TestUnmarshalSpotPriceFromOsmosisClPool() { spotPrice, err := keeper.UnmarshalSpotPriceFromOsmosisClPool(tc.tokenPrice, tc.poolData) if tc.expectedError != "" { - s.Require().Error(err) - s.Require().Contains(err.Error(), tc.expectedError) + s.Require().ErrorContains(err, tc.expectedError) } else { s.Require().NoError(err) s.Require().InDelta( diff --git a/x/icqoracle/keeper/keeper.go b/x/icqoracle/keeper/keeper.go index 18d8f61f7e..1a77e5362f 100644 --- a/x/icqoracle/keeper/keeper.go +++ b/x/icqoracle/keeper/keeper.go @@ -3,12 +3,9 @@ package keeper import ( "fmt" - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -39,229 +36,3 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - -// SetTokenPrice stores price query for a token -func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) error { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) - - bz, err := k.cdc.Marshal(&tokenPrice) - if err != nil { - return err - } - - store.Set(key, bz) - return nil -} - -// RemoveTokenPrice removes price query for a token -func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) - store.Delete(key) -} - -// Updates the token price when a query is requested -func (k Keeper) SetTokenPriceQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) error { - tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom, osmosisPoolId) - if err != nil { - return err - } - - tokenPrice.QueryInProgress = true - tokenPrice.LastRequestTime = ctx.BlockTime() - - err = k.SetTokenPrice(ctx, tokenPrice) - if err != nil { - return err - } - - return nil -} - -// Updates the token price when a query response is received -func (k Keeper) SetTokenPriceQueryComplete(ctx sdk.Context, tokenPrice types.TokenPrice, newSpotPrice math.LegacyDec) error { - tokenPrice.SpotPrice = newSpotPrice - tokenPrice.QueryInProgress = false - tokenPrice.LastResponseTime = ctx.BlockTime() - - if err := k.SetTokenPrice(ctx, tokenPrice); err != nil { - return errorsmod.Wrap(err, "Error updating spot price from query response") - } - - return nil -} - -// GetTokenPrice retrieves price data for a token -func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) (types.TokenPrice, error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) - - bz := store.Get(key) - if bz == nil { - return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%d'", baseDenom, quoteDenom, osmosisPoolId) - } - - var price types.TokenPrice - if err := k.cdc.Unmarshal(bz, &price); err != nil { - return types.TokenPrice{}, err - } - - return price, nil -} - -// GetTokenPriceByDenom retrieves all price data for a base denom -// Returned as a mapping of each quote denom to the spot price -func (k Keeper) GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*types.TokenPrice, error) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PriceQueryPrefix) - - // Create prefix iterator for all keys starting with baseDenom - iterator := sdk.KVStorePrefixIterator(store, types.TokenPriceByDenomKey(baseDenom)) - defer iterator.Close() - - prices := make(map[string]*types.TokenPrice) - - for ; iterator.Valid(); iterator.Next() { - var price types.TokenPrice - if err := k.cdc.Unmarshal(iterator.Value(), &price); err != nil { - return nil, err - } - - // Use quoteDenom as the map key - prices[price.QuoteDenom] = &price - } - - return prices, nil -} - -// GetTokenPriceForQuoteDenom calculates and retrieves the exchange rate between two tokens. -// The exchange rate is determined by finding a common quote token between both tokens, -// and then dividing their respective spot prices. -// -// For example, if we have: -// - baseToken/USDC = 10 -// - quoteToken/USDC = 5 -// -// Then: -// - baseToken/quoteToken = 10/5 = 2 -// -// Parameters: -// - ctx: SDK Context for accessing the store -// - baseDenom: The denom of the token to get the price for -// - quoteDenom: The denom to price the base token in -// -// Returns: -// - math.LegacyDec: The exchange rate of 1 baseToken in terms of quoteToken -// - error: Returns an error if: -// - No prices exist for either token -// - No common quote token exists between the two tokens -// - All available prices with a common quote token are stale (exceeded the stale timeout) -func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, quoteDenom string) (price math.LegacyDec, err error) { - // Get all price for baseToken - baseTokenPrices, err := k.GetTokenPricesByDenom(ctx, baseDenom) - if err != nil { - return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", baseDenom, err) - } - if len(baseTokenPrices) == 0 { - return math.LegacyDec{}, fmt.Errorf("no price for baseDenom '%s'", baseDenom) - } - - // Get price expiration timeout - params, err := k.GetParams(ctx) - if err != nil { - return math.LegacyDec{}, fmt.Errorf("error getting params: %w", err) - } - priceExpirationTimeoutSec := int64(params.PriceExpirationTimeoutSec) - - // Check if baseDenom already has a price for quoteDenom - foundAlreadyHasStalePrice := false - if price, ok := baseTokenPrices[quoteDenom]; ok { - if ctx.BlockTime().Unix()-price.LastRequestTime.Unix() <= priceExpirationTimeoutSec { - return price.SpotPrice, nil - } else { - foundAlreadyHasStalePrice = true - } - } - - // Get all price for quoteToken - quoteTokenPrices, err := k.GetTokenPricesByDenom(ctx, quoteDenom) - if err != nil { - return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", quoteDenom, err) - } - if len(quoteTokenPrices) == 0 { - return math.LegacyDec{}, fmt.Errorf("no price for quoteDenom '%s' (foundAlreadyHasStalePrice='%v')", quoteDenom, foundAlreadyHasStalePrice) - } - - // Init price - price = math.LegacyZeroDec() - - // Define flags to allow for better error messages - foundCommonQuoteToken := false - foundBaseTokenStalePrice := false - foundQuoteTokenStalePrice := false - foundQuoteTokenZeroPrice := false - - // Find a common quote denom and calculate baseToken to quoteToken price - for commonQuoteDenom1, baseTokenPrice := range baseTokenPrices { - for commonQuoteDenom2, quoteTokenPrice := range quoteTokenPrices { - if commonQuoteDenom1 == commonQuoteDenom2 { - foundCommonQuoteToken = true - - // Check that both prices are not stale - if ctx.BlockTime().Unix()-baseTokenPrice.LastRequestTime.Unix() > priceExpirationTimeoutSec { - foundBaseTokenStalePrice = true - continue - } - if ctx.BlockTime().Unix()-quoteTokenPrice.LastRequestTime.Unix() > priceExpirationTimeoutSec { - foundQuoteTokenStalePrice = true - continue - } - - // Check that quote price is not zero to prevent division by zero - if quoteTokenPrice.SpotPrice.IsZero() { - foundQuoteTokenZeroPrice = true - continue - } - - // Calculate the price of 1 baseToken in quoteToken - price = baseTokenPrice.SpotPrice.Quo(quoteTokenPrice.SpotPrice) - break - } - } - } - - if price.IsZero() { - return math.LegacyDec{}, fmt.Errorf( - "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v', foundQuoteTokenZeroPrice='%v', foundAlreadyHasStalePrice='%v')", - baseDenom, - quoteDenom, - foundCommonQuoteToken, - foundBaseTokenStalePrice, - foundQuoteTokenStalePrice, - foundQuoteTokenZeroPrice, - foundAlreadyHasStalePrice, - ) - } - - return price, nil -} - -// GetAllTokenPrices retrieves all stored token prices -func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { - iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), []byte(types.PriceQueryPrefix)) - defer iterator.Close() - - prices := []types.TokenPrice{} - for ; iterator.Valid(); iterator.Next() { - var price types.TokenPrice - k.cdc.MustUnmarshal(iterator.Value(), &price) - prices = append(prices, price) - } - - return prices -} - -// GetStoreKey returns the store key -func (k Keeper) GetStoreKey() storetypes.StoreKey { - return k.storeKey -} diff --git a/x/icqoracle/keeper/keeper_test.go b/x/icqoracle/keeper/keeper_test.go index 47f1b5e8c9..da7ba9cf41 100644 --- a/x/icqoracle/keeper/keeper_test.go +++ b/x/icqoracle/keeper/keeper_test.go @@ -16,7 +16,6 @@ import ( type KeeperTestSuite struct { apptesting.AppTestHelper mockICQKeeper types.IcqKeeper - icqCallbacks keeper.ICQCallbacks } // Helper function to setup keeper with mock ICQ keeper @@ -34,14 +33,8 @@ func (s *KeeperTestSuite) SetupTest() { s.Setup() s.SetupMockICQKeeper() + // Set the time to test price staleness s.Ctx = s.Ctx.WithBlockTime(time.Now().UTC()) - - // Register ICQ callback - s.icqCallbacks = s.App.ICQOracleKeeper.ICQCallbackHandler() - s.icqCallbacks.RegisterICQCallbacks() - - s.Require().True(s.icqCallbacks.HasICQCallback(keeper.ICQCallbackID_OsmosisClPool), - "OsmosisClPool callback should be registered") } // Dynamically gets the MsgServer for this module's keeper @@ -63,8 +56,3 @@ func (s *KeeperTestSuite) MustGetTokenPrice(baseDenom string, quoteDenom string, s.Require().NoError(err, "no error expected when getting token price") return tp } - -func (s *KeeperTestSuite) DeleteParams() { - store := s.Ctx.KVStore(s.App.ICQOracleKeeper.GetStoreKey()) - store.Delete([]byte(types.ParamsKey)) -} diff --git a/x/icqoracle/keeper/msg_server.go b/x/icqoracle/keeper/msg_server.go index 8585da06ef..558fc59b52 100644 --- a/x/icqoracle/keeper/msg_server.go +++ b/x/icqoracle/keeper/msg_server.go @@ -41,11 +41,7 @@ func (ms msgServer) RegisterTokenPriceQuery(goCtx context.Context, msg *types.Ms SpotPrice: sdkmath.LegacyZeroDec(), QueryInProgress: false, } - - err = ms.Keeper.SetTokenPrice(ctx, tokenPrice) - if err != nil { - return nil, err - } + ms.Keeper.SetTokenPrice(ctx, tokenPrice) return &types.MsgRegisterTokenPriceQueryResponse{}, nil } diff --git a/x/icqoracle/keeper/msg_server_test.go b/x/icqoracle/keeper/msg_server_test.go index 8e3b9d83bd..1d757ba798 100644 --- a/x/icqoracle/keeper/msg_server_test.go +++ b/x/icqoracle/keeper/msg_server_test.go @@ -50,8 +50,7 @@ func (s *KeeperTestSuite) TestRemoveTokenPriceQuery() { LastRequestTime: time.Now().UTC(), QueryInProgress: false, } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting token price") + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Remove the token price msg := types.MsgRemoveTokenPriceQuery{ @@ -59,7 +58,7 @@ func (s *KeeperTestSuite) TestRemoveTokenPriceQuery() { QuoteDenom: tokenPrice.QuoteDenom, OsmosisPoolId: tokenPrice.OsmosisPoolId, } - _, err = s.GetMsgServer().RemoveTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) + _, err := s.GetMsgServer().RemoveTokenPriceQuery(sdk.UnwrapSDKContext(s.Ctx), &msg) s.Require().NoError(err, "no error expected when removing token price query") // Confirm the token price was removed diff --git a/x/icqoracle/keeper/params.go b/x/icqoracle/keeper/params.go index 022f97367c..2b7e64c1a5 100644 --- a/x/icqoracle/keeper/params.go +++ b/x/icqoracle/keeper/params.go @@ -7,21 +7,16 @@ import ( ) // GetParams get params -func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { store := ctx.KVStore(k.storeKey) - bz := store.Get([]byte(types.ParamsKey)) - params := types.Params{} - err := k.cdc.UnmarshalJSON(bz, ¶ms) - return params, err + bz := store.Get(types.ParamsKey) + k.cdc.MustUnmarshal(bz, ¶ms) + return params } // SetParams set params -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.MarshalJSON(¶ms) - if err != nil { - return err - } - store.Set([]byte(types.ParamsKey), bz) - return nil + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) } diff --git a/x/icqoracle/keeper/params_test.go b/x/icqoracle/keeper/params_test.go index 7367394937..85826b455d 100644 --- a/x/icqoracle/keeper/params_test.go +++ b/x/icqoracle/keeper/params_test.go @@ -9,10 +9,8 @@ func (s *KeeperTestSuite) TestParams() { UpdateIntervalSec: 5 * 60, // 5 min PriceExpirationTimeoutSec: 15 * 60, // 15 min } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) - s.Require().NoError(err, "should not error on set params") + s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) - actualParams, err := s.App.ICQOracleKeeper.GetParams(s.Ctx) - s.Require().NoError(err, "should not error on get params") + actualParams := s.App.ICQOracleKeeper.GetParams(s.Ctx) s.Require().Equal(expectedParams, actualParams, "params") } diff --git a/x/icqoracle/keeper/query.go b/x/icqoracle/keeper/query.go index f11c4ec182..4ba93db786 100644 --- a/x/icqoracle/keeper/query.go +++ b/x/icqoracle/keeper/query.go @@ -59,10 +59,7 @@ func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*t ctx := sdk.UnwrapSDKContext(goCtx) - params, err := k.GetParams(ctx) - if err != nil { - return nil, err - } + params := k.GetParams(ctx) return &types.QueryParamsResponse{ Params: params, diff --git a/x/icqoracle/keeper/query_test.go b/x/icqoracle/keeper/query_test.go index 56aa1956f8..9241f83346 100644 --- a/x/icqoracle/keeper/query_test.go +++ b/x/icqoracle/keeper/query_test.go @@ -22,8 +22,7 @@ func (s *KeeperTestSuite) TestQueryTokenPrice() { OsmosisPoolId: poolId, SpotPrice: expectedPrice, } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Query for the token price req := &types.QueryTokenPriceRequest{ @@ -67,8 +66,8 @@ func (s *KeeperTestSuite) TestQueryTokenPrices() { } for _, price := range expectedPrices { - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, price) - s.Require().NoError(err, "no error expected when setting token price %+v", price) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, price) + } // Query all token prices @@ -90,8 +89,7 @@ func (s *KeeperTestSuite) TestQueryParams() { UpdateIntervalSec: 5 * 60, // 5 min PriceExpirationTimeoutSec: 15 * 60, // 15 min } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) - s.Require().NoError(err, "no error expected when setting params") + s.App.ICQOracleKeeper.SetParams(s.Ctx, expectedParams) // Query parameters req := &types.QueryParamsRequest{} @@ -104,22 +102,11 @@ func (s *KeeperTestSuite) TestQueryParams() { s.Require().Error(err, "error expected when querying with nil request") } -func (s *KeeperTestSuite) TestQueryParamsError() { - s.DeleteParams() - - // Query parameters - req := &types.QueryParamsRequest{} - _, err := s.App.ICQOracleKeeper.Params(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "error expected when querying params") - s.Require().Contains(err.Error(), "EOF") -} - func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { // Setup params - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ + s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ PriceExpirationTimeoutSec: 60, }) - s.Require().NoError(err, "no error expected when setting params") // Create token price with same quote denom baseDenom := "uatom" @@ -133,8 +120,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { SpotPrice: expectedPrice, LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Query for token price using quote denom req := &types.QueryTokenPriceForQuoteDenomRequest{ @@ -159,10 +145,9 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomSimple() { } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ + s.App.ICQOracleKeeper.SetParams(s.Ctx, types.Params{ PriceExpirationTimeoutSec: 60, }) - s.Require().NoError(err, "no error expected when setting params") // Create two token prices with same quote denom baseDenom1 := "uatom" @@ -179,8 +164,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { SpotPrice: expectedPrice1, LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice1) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) // Set uosmo price tokenPrice2 := types.TokenPrice{ @@ -190,8 +174,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenom() { SpotPrice: expectedPrice2, LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) - s.Require().NoError(err, "no error expected when setting token price %+v", tokenPrice2) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) // Query for token price using a common quote denom req := &types.QueryTokenPriceForQuoteDenomRequest{ @@ -208,8 +191,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { params := types.Params{ PriceExpirationTimeoutSec: 60, // 1 minute timeout } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Create token prices baseDenom := "uatom" @@ -223,8 +205,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { SpotPrice: expectedPrice, LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) // Fast forward block time to make price stale s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Minute * 2)) @@ -234,9 +215,8 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStalePrice() { BaseDenom: baseDenom, QuoteDenom: quoteDenom, } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "expected error for stale price") - s.Require().Contains(err.Error(), "foundAlreadyHasStalePrice='true'", "error should indicate price calculation failure") + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().ErrorContains(err, "foundAlreadyHasStalePrice='true'", "error should indicate price calculation failure") } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { @@ -253,8 +233,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) // Set quote token price with zero value tokenPrice2 := types.TokenPrice{ @@ -264,17 +243,15 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomZeroPrice() { SpotPrice: sdkmath.LegacyZeroDec(), LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) // Query should fail due to zero price req := &types.QueryTokenPriceForQuoteDenomRequest{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "expected error for zero price") - s.Require().Contains(err.Error(), "could not calculate price", "error should indicate price calculation failure") + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().ErrorContains(err, "could not calculate price", "error should indicate price calculation failure") } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { @@ -290,8 +267,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) // Set quote token price with different quote denom tokenPrice2 := types.TokenPrice{ @@ -301,43 +277,15 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoCommonQuote() { SpotPrice: sdkmath.LegacyNewDec(2000000), LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) // Query should fail due to no common quote denom req := &types.QueryTokenPriceForQuoteDenomRequest{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "expected error when no common quote denom exists") - s.Require().Contains(err.Error(), "could not calculate price", "error should indicate price calculation failure") -} - -func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomParamsError() { - s.DeleteParams() - - baseDenom := "uatom" - - // Set base token price with one quote denom - tokenPrice1 := types.TokenPrice{ - BaseDenom: baseDenom, - QuoteDenom: "quote1", - OsmosisPoolId: 1, - SpotPrice: sdkmath.LegacyNewDec(1000000), - LastRequestTime: s.Ctx.BlockTime(), - } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err) - - // Query for token price using quote denom - req := &types.QueryTokenPriceForQuoteDenomRequest{ - BaseDenom: baseDenom, - QuoteDenom: "banana", - } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "error expected when querying token price for quote denom") - s.Require().Contains(err.Error(), "error getting params") + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().ErrorContains(err, "could not calculate price", "error should indicate price calculation failure") } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoBaseDenom() { @@ -346,8 +294,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoBaseDenom() { QuoteDenom: "papaya", } _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "error expected when querying token price for quote denom") - s.Require().Contains(err.Error(), "no price for baseDenom 'banana'") + s.Require().ErrorContains(err, "no price for baseDenom 'banana'") } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoQuoteDenom() { @@ -359,16 +306,14 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomNoQuoteDenom() { SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } - err := s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) req := &types.QueryTokenPriceForQuoteDenomRequest{ BaseDenom: "banana", QuoteDenom: "papaya", } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "error expected when querying token price for quote denom") - s.Require().Contains(err.Error(), "no price for quoteDenom 'papaya'") + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().ErrorContains(err, "no price for quoteDenom 'papaya'") } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { @@ -376,8 +321,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { params := types.Params{ PriceExpirationTimeoutSec: 60, // 1 minute timeout } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Create token prices with same quote denom baseDenom := "uatom" @@ -392,8 +336,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) // Set quote token price (fresh) tokenPrice2 := types.TokenPrice{ @@ -403,17 +346,15 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleBasePrice() { SpotPrice: sdkmath.LegacyNewDec(2000000), LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) // Query should fail due to stale base price req := &types.QueryTokenPriceForQuoteDenomRequest{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "expected error for stale base price") - s.Require().Contains(err.Error(), "foundBaseTokenStalePrice='true'", "error should indicate base token price is stale") + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().ErrorContains(err, "foundBaseTokenStalePrice='true'", "error should indicate base token price is stale") } func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { @@ -421,8 +362,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { params := types.Params{ PriceExpirationTimeoutSec: 60, // 1 minute timeout } - err := s.App.ICQOracleKeeper.SetParams(s.Ctx, params) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetParams(s.Ctx, params) // Create token prices with same quote denom baseDenom := "uatom" @@ -437,8 +377,7 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { SpotPrice: sdkmath.LegacyNewDec(1000000), LastRequestTime: s.Ctx.BlockTime(), } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice1) // Set quote token price (will be stale) tokenPrice2 := types.TokenPrice{ @@ -448,15 +387,13 @@ func (s *KeeperTestSuite) TestQueryTokenPriceForQuoteDenomStaleQuotePrice() { SpotPrice: sdkmath.LegacyNewDec(2000000), LastRequestTime: s.Ctx.BlockTime().Add(-2 * time.Minute), // Stale } - err = s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) - s.Require().NoError(err) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice2) // Query should fail due to stale quote price req := &types.QueryTokenPriceForQuoteDenomRequest{ BaseDenom: baseDenom, QuoteDenom: quoteDenom, } - _, err = s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) - s.Require().Error(err, "expected error for stale quote price") - s.Require().Contains(err.Error(), "foundQuoteTokenStalePrice='true'", "error should indicate quote token price is stale") + _, err := s.App.ICQOracleKeeper.TokenPriceForQuoteDenom(sdk.WrapSDKContext(s.Ctx), req) + s.Require().ErrorContains(err, "foundQuoteTokenStalePrice='true'", "error should indicate quote token price is stale") } diff --git a/x/icqoracle/keeper/token_price.go b/x/icqoracle/keeper/token_price.go new file mode 100644 index 0000000000..1054290cc6 --- /dev/null +++ b/x/icqoracle/keeper/token_price.go @@ -0,0 +1,216 @@ +package keeper + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v25/x/icqoracle/types" +) + +// SetTokenPrice stores price query for a token +func (k Keeper) SetTokenPrice(ctx sdk.Context, tokenPrice types.TokenPrice) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.TokenPricePrefix) + key := types.TokenPriceKey(tokenPrice.BaseDenom, tokenPrice.QuoteDenom, tokenPrice.OsmosisPoolId) + bz := k.cdc.MustMarshal(&tokenPrice) + store.Set(key, bz) +} + +// RemoveTokenPrice removes price query for a token +func (k Keeper) RemoveTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.TokenPricePrefix) + key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) + store.Delete(key) +} + +// Updates the token price when a query is requested +func (k Keeper) SetQueryInProgress(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) error { + tokenPrice, err := k.GetTokenPrice(ctx, baseDenom, quoteDenom, osmosisPoolId) + if err != nil { + return err + } + + tokenPrice.QueryInProgress = true + tokenPrice.LastRequestTime = ctx.BlockTime() + + k.SetTokenPrice(ctx, tokenPrice) + + return nil +} + +// Updates the token price when a query response is received +func (k Keeper) SetQueryComplete(ctx sdk.Context, tokenPrice types.TokenPrice, newSpotPrice math.LegacyDec) { + tokenPrice.SpotPrice = newSpotPrice + tokenPrice.QueryInProgress = false + tokenPrice.LastResponseTime = ctx.BlockTime() + k.SetTokenPrice(ctx, tokenPrice) +} + +// GetTokenPrice retrieves price data for a token +func (k Keeper) GetTokenPrice(ctx sdk.Context, baseDenom string, quoteDenom string, osmosisPoolId uint64) (types.TokenPrice, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.TokenPricePrefix) + key := types.TokenPriceKey(baseDenom, quoteDenom, osmosisPoolId) + + bz := store.Get(key) + if bz == nil { + return types.TokenPrice{}, fmt.Errorf("price not found for baseDenom='%s' quoteDenom='%s' poolId='%d'", baseDenom, quoteDenom, osmosisPoolId) + } + + var price types.TokenPrice + if err := k.cdc.Unmarshal(bz, &price); err != nil { + return types.TokenPrice{}, errorsmod.Wrapf(err, "unable to unmarshal token price") + } + + return price, nil +} + +// GetTokenPriceByDenom retrieves all price data for a base denom +// Returned as a mapping of each quote denom to the spot price +func (k Keeper) GetTokenPricesByDenom(ctx sdk.Context, baseDenom string) (map[string]*types.TokenPrice, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.TokenPricePrefix) + + // Create prefix iterator for all keys starting with baseDenom + iterator := sdk.KVStorePrefixIterator(store, types.TokenPriceByDenomKey(baseDenom)) + defer iterator.Close() + + prices := make(map[string]*types.TokenPrice) + + for ; iterator.Valid(); iterator.Next() { + var price types.TokenPrice + if err := k.cdc.Unmarshal(iterator.Value(), &price); err != nil { + return nil, err + } + + // Use quoteDenom as the map key + prices[price.QuoteDenom] = &price + } + + return prices, nil +} + +// GetTokenPriceForQuoteDenom calculates and retrieves the exchange rate between two tokens. +// The exchange rate is determined by finding a common quote token between both tokens, +// and then dividing their respective spot prices. +// +// For example, if we have: +// - baseToken/USDC = 10 +// - quoteToken/USDC = 5 +// +// Then: +// - baseToken/quoteToken = 10/5 = 2 +// +// Parameters: +// - ctx: SDK Context for accessing the store +// - baseDenom: The denom of the token to get the price for +// - quoteDenom: The denom to price the base token in +// +// Returns: +// - math.LegacyDec: The exchange rate of 1 baseToken in terms of quoteToken +// - error: Returns an error if: +// - No prices exist for either token +// - No common quote token exists between the two tokens +// - All available prices with a common quote token are stale (exceeded the stale timeout) +func (k Keeper) GetTokenPriceForQuoteDenom(ctx sdk.Context, baseDenom string, quoteDenom string) (price math.LegacyDec, err error) { + // Get all price for baseToken + baseTokenPrices, err := k.GetTokenPricesByDenom(ctx, baseDenom) + if err != nil { + return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", baseDenom, err) + } + if len(baseTokenPrices) == 0 { + return math.LegacyDec{}, fmt.Errorf("no price for baseDenom '%s'", baseDenom) + } + + // Get price expiration timeout + params := k.GetParams(ctx) + priceExpirationTimeoutSec := int64(params.PriceExpirationTimeoutSec) + + // Check if baseDenom already has a price for quoteDenom + foundAlreadyHasStalePrice := false + if price, ok := baseTokenPrices[quoteDenom]; ok { + if ctx.BlockTime().Unix()-price.LastRequestTime.Unix() <= priceExpirationTimeoutSec { + return price.SpotPrice, nil + } else { + foundAlreadyHasStalePrice = true + } + } + + // Get all price for quoteToken + quoteTokenPrices, err := k.GetTokenPricesByDenom(ctx, quoteDenom) + if err != nil { + return math.LegacyDec{}, fmt.Errorf("error getting price for '%s': %w", quoteDenom, err) + } + if len(quoteTokenPrices) == 0 { + return math.LegacyDec{}, fmt.Errorf("no price for quoteDenom '%s' (foundAlreadyHasStalePrice='%v')", quoteDenom, foundAlreadyHasStalePrice) + } + + // Init price + price = math.LegacyZeroDec() + + // Define flags to allow for better error messages + foundCommonQuoteToken := false + foundBaseTokenStalePrice := false + foundQuoteTokenStalePrice := false + foundQuoteTokenZeroPrice := false + + // Find a common quote denom and calculate baseToken to quoteToken price + for commonQuoteDenom1, baseTokenPrice := range baseTokenPrices { + for commonQuoteDenom2, quoteTokenPrice := range quoteTokenPrices { + if commonQuoteDenom1 == commonQuoteDenom2 { + foundCommonQuoteToken = true + + // Check that both prices are not stale + if ctx.BlockTime().Unix()-baseTokenPrice.LastRequestTime.Unix() > priceExpirationTimeoutSec { + foundBaseTokenStalePrice = true + continue + } + if ctx.BlockTime().Unix()-quoteTokenPrice.LastRequestTime.Unix() > priceExpirationTimeoutSec { + foundQuoteTokenStalePrice = true + continue + } + + // Check that quote price is not zero to prevent division by zero + if quoteTokenPrice.SpotPrice.IsZero() { + foundQuoteTokenZeroPrice = true + continue + } + + // Calculate the price of 1 baseToken in quoteToken + price = baseTokenPrice.SpotPrice.Quo(quoteTokenPrice.SpotPrice) + break + } + } + } + + if price.IsZero() { + return math.LegacyDec{}, fmt.Errorf( + "could not calculate price for baseToken='%s' quoteToken='%s' (foundCommonQuoteToken='%v', foundBaseTokenStalePrice='%v', foundQuoteTokenStalePrice='%v', foundQuoteTokenZeroPrice='%v', foundAlreadyHasStalePrice='%v')", + baseDenom, + quoteDenom, + foundCommonQuoteToken, + foundBaseTokenStalePrice, + foundQuoteTokenStalePrice, + foundQuoteTokenZeroPrice, + foundAlreadyHasStalePrice, + ) + } + + return price, nil +} + +// GetAllTokenPrices retrieves all stored token prices +func (k Keeper) GetAllTokenPrices(ctx sdk.Context) []types.TokenPrice { + iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), []byte(types.TokenPricePrefix)) + defer iterator.Close() + + prices := []types.TokenPrice{} + for ; iterator.Valid(); iterator.Next() { + var price types.TokenPrice + k.cdc.MustUnmarshal(iterator.Value(), &price) + prices = append(prices, price) + } + + return prices +} diff --git a/x/icqoracle/keeper/token_price_test.go b/x/icqoracle/keeper/token_price_test.go new file mode 100644 index 0000000000..5a9d155981 --- /dev/null +++ b/x/icqoracle/keeper/token_price_test.go @@ -0,0 +1,51 @@ +package keeper_test + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Stride-Labs/stride/v25/x/icqoracle/types" +) + +// Helper function to create 5 tokenPrice objects with various attributes +func (s *KeeperTestSuite) createTokenPrices() []types.TokenPrice { + tokenPrices := []types.TokenPrice{} + for i := int64(1); i <= 5; i++ { + tokenPrice := types.TokenPrice{ + BaseDenom: fmt.Sprintf("base-%d", i), + QuoteDenom: fmt.Sprintf("quote-%d", i), + SpotPrice: sdk.ZeroDec(), + } + + tokenPrices = append(tokenPrices, tokenPrice) + s.App.ICQOracleKeeper.SetTokenPrice(s.Ctx, tokenPrice) + } + return tokenPrices +} + +// Tests Get/Set TokenPrice +func (s *KeeperTestSuite) TestGetTokenPrice() { + tokenPrices := s.createTokenPrices() + + for _, expected := range tokenPrices { + actual, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, expected.BaseDenom, expected.QuoteDenom, expected.OsmosisPoolId) + s.Require().NoError(err, "tokenPrice %s should have been found", expected.BaseDenom) + s.Require().Equal(expected, actual) + } + + _, err := s.App.ICQOracleKeeper.GetTokenPrice(s.Ctx, "non-existent", "non-existent", 0) + s.Require().ErrorContains(err, "price not found") +} + +// Tests getting all tokenPrices +func (s *KeeperTestSuite) TestGetAllTokenPrices() { + expectedTokenPrices := s.createTokenPrices() + + actualTokenPrices := s.App.ICQOracleKeeper.GetAllTokenPrices(s.Ctx) + s.Require().Equal(len(actualTokenPrices), len(expectedTokenPrices), "number of tokenPrices") + + for i, expectedTokenPrice := range expectedTokenPrices { + s.Require().Equal(expectedTokenPrice, actualTokenPrices[i]) + } +} diff --git a/x/icqoracle/types/keys.go b/x/icqoracle/types/keys.go index 640111fa0b..9d46bc6c50 100644 --- a/x/icqoracle/types/keys.go +++ b/x/icqoracle/types/keys.go @@ -16,7 +16,7 @@ const ( var ( ParamsKey = []byte("params") - PriceQueryPrefix = []byte("pricequery") + TokenPricePrefix = []byte("tokenprice") ) func TokenPriceKey(baseDenom, quoteDenom string, poolId uint64) []byte { From 139a80624e5f05b2641959238f706e9565c45ff4 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 5 Feb 2025 22:39:32 +0200 Subject: [PATCH 115/115] refactors integration tests, make some progress with icqoracle happy path --- integration-tests/client/package.json | 2 +- integration-tests/client/pnpm-lock.yaml | 10 +- integration-tests/client/test/core.test.ts | 2 +- integration-tests/client/test/main.test.ts | 150 ++++++++++++--------- integration-tests/client/test/utils.ts | 38 ++++-- 5 files changed, 120 insertions(+), 82 deletions(-) diff --git a/integration-tests/client/package.json b/integration-tests/client/package.json index 3dfef7a28a..1be5379972 100644 --- a/integration-tests/client/package.json +++ b/integration-tests/client/package.json @@ -26,7 +26,7 @@ "bech32": "2.0.0", "jest": "29.7.0", "prettier": "3.3.3", - "stridejs": "github:Stride-Labs/stridejs#e949e35", + "stridejs": "github:Stride-Labs/stridejs#f60d3e2d6c3b0ddbbb5522ccb57a8ae33ee67bfc", "typescript": "5.5.3", "vitest": "2.0.3" }, diff --git a/integration-tests/client/pnpm-lock.yaml b/integration-tests/client/pnpm-lock.yaml index 79354fd853..bfc0093577 100644 --- a/integration-tests/client/pnpm-lock.yaml +++ b/integration-tests/client/pnpm-lock.yaml @@ -42,8 +42,8 @@ importers: specifier: 3.3.3 version: 3.3.3 stridejs: - specifier: github:Stride-Labs/stridejs#e949e35 - version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35 + specifier: github:Stride-Labs/stridejs#f60d3e2d6c3b0ddbbb5522ccb57a8ae33ee67bfc + version: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f60d3e2d6c3b0ddbbb5522ccb57a8ae33ee67bfc typescript: specifier: 5.5.3 version: 5.5.3 @@ -1669,8 +1669,8 @@ packages: std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: - resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35} + stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f60d3e2d6c3b0ddbbb5522ccb57a8ae33ee67bfc: + resolution: {tarball: https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f60d3e2d6c3b0ddbbb5522ccb57a8ae33ee67bfc} version: 0.11.4 string-length@4.0.2: @@ -3825,7 +3825,7 @@ snapshots: std-env@3.7.0: {} - stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/e949e35: + stridejs@https://codeload.github.com/Stride-Labs/stridejs/tar.gz/f60d3e2d6c3b0ddbbb5522ccb57a8ae33ee67bfc: dependencies: '@cosmjs/amino': 0.32.4 '@cosmjs/encoding': 0.32.4 diff --git a/integration-tests/client/test/core.test.ts b/integration-tests/client/test/core.test.ts index f6723dc2ae..8351d66d5a 100644 --- a/integration-tests/client/test/core.test.ts +++ b/integration-tests/client/test/core.test.ts @@ -77,7 +77,7 @@ beforeAll(async () => { await waitForChain(accounts.user, "ustrd"); }); -describe("x/stakeibc", () => { +describe.skip("x/stakeibc", () => { test("Registration", async () => { const stridejs = accounts.admin; diff --git a/integration-tests/client/test/main.test.ts b/integration-tests/client/test/main.test.ts index a2cf919675..6a8877ac71 100644 --- a/integration-tests/client/test/main.test.ts +++ b/integration-tests/client/test/main.test.ts @@ -1,5 +1,5 @@ -import { Secp256k1HdWallet } from "@cosmjs/amino"; -import { GasPrice } from "@cosmjs/stargate"; +import { OfflineAminoSigner, Secp256k1HdWallet } from "@cosmjs/amino"; +import { GasPrice, SigningStargateClient } from "@cosmjs/stargate"; import { fromSeconds } from "@cosmjs/tendermint-rpc"; import { coinFromString, @@ -12,7 +12,7 @@ import { waitForChain } from "./utils"; const STRIDE_RPC_ENDPOINT = "http://stride-rpc.internal.stridenet.co"; const GAIA_RPC_ENDPOINT = "http://cosmoshub-rpc.internal.stridenet.co"; -const OSMO_RPC_ENDPOINT = "http://localhost:26357"; +const OSMO_RPC_ENDPOINT = "http://osmosis-rpc.internal.stridenet.co"; const TRANSFER_CHANNEL = { STRIDE: { GAIA: "channel-0", OSMO: "channel-1" }, @@ -28,8 +28,23 @@ let accounts: { val3: StrideClient; }; +export type GaiaClient = { + signer: OfflineAminoSigner; + client: SigningStargateClient; +}; + +export function isGaiaClient(client: any): client is GaiaClient { + return ( + "signer" in client && + "getAccounts" in client.signer && + "signAmino" in client.signer && + "client" in client && + client.client instanceof SigningStargateClient + ); +} + let gaiaAccounts: { - user: StrideClient; // a normal account loaded with 100 ATOM + user: GaiaClient; // a normal account loaded with 100 ATOM }; const mnemonics: { @@ -101,12 +116,20 @@ beforeAll(async () => { const [{ address }] = await signer.getAccounts(); gaiaAccounts = { - user: await StrideClient.create(GAIA_RPC_ENDPOINT, signer, address, { - gasPrice: GasPrice.fromString("0.025uatom"), - broadcastPollIntervalMs: 50, - resolveIbcResponsesCheckIntervalMs: 50, - }), + user: { + signer, + client: await SigningStargateClient.connectWithSigner( + GAIA_RPC_ENDPOINT, + signer, + { + gasPrice: GasPrice.fromString("1.0uatom"), + broadcastPollIntervalMs: 50, + }, + ), + }, }; + + // TODO osmosisAccount } } console.log("waiting for stride to start..."); @@ -198,9 +221,18 @@ describe("ibc", () => { describe("x/icqoracle", () => { test.only("happy path", async () => { + // - Transfer STRD to Osmosis + // - Transfer ATOM to Osmosis + // - Create STRD/OSMO pool + // - Create ATOM/OSMO pool + // - Add TokenPrice(base=STRD, quote=OSMO) + // - Add TokenPrice(base=ATOM, quote=OSMO) + // - Query for price of ATOM in STRD + + // Transfer STRD to Osmosis const stridejs = accounts.user; - let msg = + const strideTx = await stridejs.signAndBroadcast([ stridejs.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( { sourcePort: "transfer", @@ -213,77 +245,65 @@ describe("x/icqoracle", () => { revisionHeight: 0n, }, timeoutTimestamp: BigInt( - `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes from now as nanoseconds + `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes ), memo: "", }, - ); - - let tx = await stridejs.signAndBroadcast([msg]); - if (tx.code !== 0) { - console.error(tx.rawLog); + ), + ]); + if (strideTx.code !== 0) { + console.error(strideTx.rawLog); } - expect(tx.code).toBe(0); + expect(strideTx.code).toBe(0); - let ibcAck = await tx.ibcResponses[0]; + const ibcAck = await strideTx.ibcResponses[0]; expect(ibcAck.type).toBe("ack"); expect(ibcAck.tx.code).toBe(0); - const gaiaSigner = await Secp256k1HdWallet.fromMnemonic( - mnemonics.find((x) => x.name === "user")!.mnemonic, - { - prefix: "cosmos", - }, - ); + // Transfer ATOM to Osmosis + const gaiajs = gaiaAccounts.user; - // get signer address - const [{ address: gaiaAddress }] = await gaiaSigner.getAccounts(); + const [{ address: gaiaAddress }] = await gaiajs.signer.getAccounts(); - const gaiaClient = await StrideClient.create( - GAIA_RPC_ENDPOINT, - gaiaSigner, + const gaiaTx = await gaiajs.client.signAndBroadcast( gaiaAddress, - { - gasPrice: GasPrice.fromString("0uatom"), - broadcastPollIntervalMs: 50, - resolveIbcResponsesCheckIntervalMs: 50, - }, - ); - - msg = - gaiaClient.types.ibc.applications.transfer.v1.MessageComposer.withTypeUrl.transfer( + [ { - sourcePort: "transfer", - sourceChannel: TRANSFER_CHANNEL["GAIA"]["STRIDE"], - token: coinFromString("1000000uatom"), - sender: gaiaAddress, - receiver: convertBech32Prefix(gaiaAddress, "stride"), // ignored by pfm - timeoutHeight: { - revisionNumber: 0n, - revisionHeight: 0n, - }, - timeoutTimestamp: BigInt( - `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes from now as nanoseconds - ), - memo: JSON.stringify({ - forward: { - receiver: convertBech32Prefix(gaiaAddress, "osmo"), - port: "transfer", - channel: TRANSFER_CHANNEL["STRIDE"]["OSMO"], + typeUrl: "/ibc.applications.transfer.v1.MsgTransfer", + value: { + sourcePort: "transfer", + sourceChannel: TRANSFER_CHANNEL["GAIA"]["STRIDE"], + token: coinFromString("1000000uatom"), + sender: gaiaAddress, + receiver: convertBech32Prefix(gaiaAddress, "stride"), // needs to be valid but ignored by pfm + timeoutHeight: { + revisionNumber: 0n, + revisionHeight: 0n, }, - }), + timeoutTimestamp: BigInt( + `${Math.floor(Date.now() / 1000) + 3 * 60}000000000`, // 3 minutes + ), + memo: JSON.stringify({ + forward: { + receiver: convertBech32Prefix(gaiaAddress, "osmo"), + port: "transfer", + channel: TRANSFER_CHANNEL["STRIDE"]["OSMO"], + }, + }), + }, }, - ); + ], + "auto", + ); - tx = await stridejs.signAndBroadcast([msg]); - if (tx.code !== 0) { - console.error(tx.rawLog); + if (gaiaTx.code !== 0) { + console.error(gaiaTx.rawLog); } - expect(tx.code).toBe(0); + expect(gaiaTx.code).toBe(0); - // packet forward should resolve only after the final destination is acked - ibcAck = await tx.ibcResponses[0]; - expect(ibcAck.type).toBe("ack"); - expect(ibcAck.tx.code).toBe(0); + // // packet forward should resolve only after the final destination is acked + // ibcAck = await tx.ibcResponses[0]; + // expect(ibcAck.type).toBe("ack"); + // expect(ibcAck.tx.code).toBe(0); }, 120_000); }); diff --git a/integration-tests/client/test/utils.ts b/integration-tests/client/test/utils.ts index af7608e827..80761c7914 100644 --- a/integration-tests/client/test/utils.ts +++ b/integration-tests/client/test/utils.ts @@ -1,5 +1,7 @@ +import { SigningStargateClient } from "@cosmjs/stargate"; import { coinsFromString, EncodeObject, StrideClient } from "stridejs"; import { expect } from "vitest"; +import { GaiaClient, isGaiaClient } from "./main.test"; /** * Waits for the chain to start by continuously sending transactions until . @@ -8,27 +10,43 @@ import { expect } from "vitest"; * @param {string} denom The denomination of the coins to send. */ export async function waitForChain( - client: StrideClient, + client: StrideClient | GaiaClient, denom: string, ): Promise { // the best way to ensure a chain is up is to successfully send a tx while (true) { try { - const msg = - client.types.cosmos.bank.v1beta1.MessageComposer.withTypeUrl.send({ - fromAddress: client.address, - toAddress: client.address, - amount: coinsFromString(`1${denom}`), - }); + if (client instanceof StrideClient) { + const msg = + client.types.cosmos.bank.v1beta1.MessageComposer.withTypeUrl.send({ + fromAddress: client.address, + toAddress: client.address, + amount: coinsFromString(`1${denom}`), + }); - const tx = await client.signAndBroadcast([msg], 2); + const tx = await client.signAndBroadcast([msg], 2); - if (tx.code == 0) { - break; + if (tx.code === 0) { + break; + } + } else if (isGaiaClient(client)) { + const [{ address }] = await client.signer.getAccounts(); + + const tx = await client.client.sendTokens( + address, + address, + coinsFromString(`1${denom}`), + 2, + ); + + if (tx.code === 0) { + break; + } } } catch (e) { // signAndBroadcast might throw if the RPC is not up yet + // console.log(e); } } }