-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c0d9bd
commit 9151ea8
Showing
29 changed files
with
4,927 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
package milkyway.tickers.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "milkyway/tickers/v1/params.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/tickers/types"; | ||
|
||
// GenesisState defines the module's genesis state. | ||
message GenesisState { | ||
// Params defines the parameters of the module. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
|
||
map<string, string> tickers = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
syntax = "proto3"; | ||
package milkyway.tickers.v1; | ||
|
||
import "amino/amino.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "milkyway/tickers/v1/params.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/tickers/types"; | ||
|
||
// Msg defines the services module's gRPC message service. | ||
service Msg { | ||
option (cosmos.msg.v1.service) = true; | ||
|
||
rpc RegisterTicker(MsgRegisterTicker) returns (MsgRegisterTickerResponse); | ||
|
||
rpc DeregisterTicker(MsgDeregisterTicker) | ||
returns (MsgDeregisterTickerResponse); | ||
|
||
// UpdateParams defines a (governance) operation for updating the module | ||
// parameters. | ||
// The authority defaults to the x/gov module account. | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
} | ||
|
||
message MsgRegisterTicker { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
option (amino.name) = "tickers/MsgRegisterTicker"; | ||
|
||
// Authority is the address that controls the module (defaults to x/gov unless | ||
// overwritten). | ||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
string denom = 2; | ||
|
||
string ticker = 3; | ||
} | ||
|
||
message MsgRegisterTickerResponse {} | ||
|
||
message MsgDeregisterTicker { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
option (amino.name) = "tickers/MsgDeregisterTicker"; | ||
|
||
// Authority is the address that controls the module (defaults to x/gov unless | ||
// overwritten). | ||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
string denom = 2; | ||
} | ||
|
||
message MsgDeregisterTickerResponse {} | ||
|
||
// MsgUpdateParams defines the message structure for the UpdateParams gRPC | ||
// service method. It allows the authority to update the module parameters. | ||
message MsgUpdateParams { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
option (amino.name) = "tickers/MsgUpdateParams"; | ||
|
||
// Authority is the address that controls the module (defaults to x/gov unless | ||
// overwritten). | ||
string authority = 1 [ | ||
(gogoproto.moretags) = "yaml:\"authority\"", | ||
(cosmos_proto.scalar) = "cosmos.AddressString" | ||
]; | ||
|
||
// Params define the parameters to update. | ||
// | ||
// NOTE: All parameters must be supplied. | ||
Params params = 2 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// MsgUpdateParamsResponse is the return value of MsgUpdateParams. | ||
message MsgUpdateParamsResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
syntax = "proto3"; | ||
package milkyway.tickers.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/tickers/types"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
package milkyway.tickers.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/tickers/types"; | ||
|
||
// Params defines the parameters for the module. | ||
message Params {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
syntax = "proto3"; | ||
package milkyway.tickers.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "milkyway/tickers/v1/params.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/tickers/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params defines a gRPC query method that returns the parameters of the | ||
// module. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/milkyway/tickers/v1/params"; | ||
} | ||
|
||
rpc Ticker(QueryTickerRequest) returns (QueryTickerResponse) { | ||
option (google.api.http).get = "/milkyway/tickers/v1/tickers/{denom}"; | ||
} | ||
|
||
rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { | ||
option (google.api.http).get = "/milkyway/tickers/v1/denoms/{ticker}"; | ||
} | ||
} | ||
|
||
// 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 ]; | ||
} | ||
|
||
message QueryTickerRequest { string denom = 1; } | ||
|
||
message QueryTickerResponse { string ticker = 1; } | ||
|
||
message QueryDenomsRequest { | ||
string ticker = 1; | ||
|
||
cosmos.base.query.v1beta1.PageRequest pagination = 2; | ||
} | ||
|
||
message QueryDenomsResponse { | ||
repeated string denoms = 1; | ||
|
||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/version" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/milkyway-labs/milkyway/x/tickers/types" | ||
) | ||
|
||
// GetQueryCmd returns the command allowing to perform queries | ||
func GetQueryCmd() *cobra.Command { | ||
queryCmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
queryCmd.AddCommand( | ||
GetCmdQueryParams(), | ||
GetCmdQueryTicker(), | ||
GetCmdQueryDenoms(), | ||
) | ||
|
||
return queryCmd | ||
} | ||
|
||
// GetCmdQueryParams returns the command to query the module params | ||
func GetCmdQueryParams() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "params", | ||
Short: "Query the module parameters", | ||
Example: fmt.Sprintf(`%s query %s params`, version.AppName, types.ModuleName), | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} | ||
|
||
// GetCmdQueryTicker returns the command allowing to query the ticker by a denom | ||
func GetCmdQueryTicker() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "ticker [denom]", | ||
Short: "Query the ticker of a given denom", | ||
Example: fmt.Sprintf(`%s query %s ticker umilk`, version.AppName, types.ModuleName), | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
denom := args[0] | ||
|
||
res, err := queryClient.Ticker(cmd.Context(), &types.QueryTickerRequest{Denom: denom}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} | ||
|
||
// GetCmdQueryDenoms returns the command allowing to query all the denoms for | ||
// a given ticker | ||
func GetCmdQueryDenoms() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "denoms [ticker]", | ||
Short: "Query all the denoms of a given ticker", | ||
Example: fmt.Sprintf(`%s query %s denoms MILK`, version.AppName, types.ModuleName), | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
ticker := args[0] | ||
|
||
pageReq, err := client.ReadPageRequest(cmd.Flags()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
res, err := queryClient.Denoms(cmd.Context(), &types.QueryDenomsRequest{ | ||
Ticker: ticker, Pagination: pageReq, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
flags.AddPaginationFlagsToCmd(cmd, "denoms") | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/milkyway-labs/milkyway/x/tickers/types" | ||
) | ||
|
||
// GetTxCmd returns a new command to perform transactions | ||
func GetTxCmd() *cobra.Command { | ||
txCmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: "Tickers transaction subcommands", | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
txCmd.AddCommand() | ||
|
||
return txCmd | ||
} |
Oops, something went wrong.