Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Aug 8, 2021
1 parent f9b6939 commit b6a5f4c
Show file tree
Hide file tree
Showing 20 changed files with 2,098 additions and 99 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/osmosis-labs/osmosis
go 1.15

require (
github.com/cosmos/cosmos-sdk v0.42.8
github.com/cosmos/cosmos-sdk v0.42.9
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.16.0
github.com/gogo/protobuf v1.3.3
Expand Down
6 changes: 3 additions & 3 deletions proto/osmosis/gamm/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option go_package = "github.com/osmosis-labs/osmosis/x/gamm/types";

// GenesisState defines the gamm module's genesis state.
message GenesisState {
repeated google.protobuf.Any pools = 1
[ (cosmos_proto.accepts_interface) = "PoolI" ];
uint64 next_pool_number = 2;
repeated google.protobuf.Any pools = 1
[ (cosmos_proto.accepts_interface) = "PoolI" ];
uint64 next_pool_number = 2;
}
4 changes: 2 additions & 2 deletions proto/osmosis/lockup/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ option go_package = "github.com/osmosis-labs/osmosis/x/lockup/types";

// GenesisState defines the lockup module's genesis state.
message GenesisState {
uint64 last_lock_id = 1;
repeated PeriodLock locks = 2 [ (gogoproto.nullable) = false ];
uint64 last_lock_id = 1;
repeated PeriodLock locks = 2 [ (gogoproto.nullable) = false ];
}
6 changes: 4 additions & 2 deletions proto/osmosis/txfees/v1beta1/feetoken.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/osmosis-labs/osmosis/x/txfees/types";

message FeeToken {
string denom = 1;
uint64 poolID = 2;
option (gogoproto.equal) = true;

string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
uint64 poolID = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
}
7 changes: 6 additions & 1 deletion proto/osmosis/txfees/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ message UpdateFeeTokenProposal {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

FeeToken feetoken = 1 [ (gogoproto.nullable) = false ];
string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
FeeToken feetoken = 3 [
(gogoproto.moretags) = "yaml:\"fee_token\"",
(gogoproto.nullable) = false
];
}
42 changes: 37 additions & 5 deletions proto/osmosis/txfees/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
syntax = "proto3";
package osmosis.txfees.v1beta1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
// this line is used by starport scaffolding # 1
import "google/protobuf/duration.proto";

import "osmosis/txfees/v1beta1/feetoken.proto";

option go_package = "github.com/osmosis-labs/osmosis/x/txfees/types";

// Query defines the gRPC querier service.
service Query {
// this line is used by starport scaffolding # 2
// GaugeIds takes the pool id and returns the matching gauge ids and durations
rpc FeeTokens(QueryFeeTokensRequest) returns (QueryFeeTokensResponse) {
option (google.api.http).get = "/osmosis/txfees/v1beta1/fee_tokens";
}

rpc DenomPoolId(QueryDenomPoolIdRequest) returns (QueryDenomPoolIdResponse) {
option (google.api.http).get =
"/osmosis/txfees/v1beta1/denon_pool_id/{denom}";
}

rpc BaseDenom(QueryBaseDenomRequest) returns (QueryBaseDenomResponse) {
option (google.api.http).get = "/osmosis/txfees/v1beta1/base_denom";
}
}

message QueryFeeTokensRequest {}
message QueryFeeTokensResponse {

repeated FeeToken fee_tokens = 1 [
(gogoproto.moretags) = "yaml:\"fee_tokens\"",
(gogoproto.nullable) = false
];
}

// this line is used by starport scaffolding # 3
message QueryDenomPoolIdRequest {
string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
}
message QueryDenomPoolIdResponse {
uint64 poolID = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
}

message QueryBaseDenomRequest {}
message QueryBaseDenomResponse {
string base_denom = 1 [ (gogoproto.moretags) = "yaml:\"base_denom\"" ];
}
2 changes: 2 additions & 0 deletions x/incentives/types/query.pb.go

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

2 changes: 1 addition & 1 deletion x/lockup/types/tx.pb.go

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

129 changes: 120 additions & 9 deletions x/txfees/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ package cli

import (
"fmt"
// "strings"

"github.com/spf13/cobra"
"strings"

"github.com/cosmos/cosmos-sdk/client"
// "github.com/cosmos/cosmos-sdk/client/flags"
// sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/osmosis-labs/osmosis/x/txfees/types"
"github.com/spf13/cobra"
)

// GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string) *cobra.Command {
// Group txfees queries under a subcommand
// Group queries under a subcommand
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
Expand All @@ -24,8 +22,121 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
RunE: client.ValidateCmd,
}

// this line is used by starport scaffolding # 1
cmd.AddCommand(
GetCmdFeeTokens(),
GetCmdDenomPoolID(),
GetCmdBaseDenom(),
)

return cmd
}

// GetCmdGaugeIds takes the pool id and returns the matching gauge ids and durations
func GetCmdFeeTokens() *cobra.Command {
cmd := &cobra.Command{
Use: "fee-tokens",
Short: "Query the list of non-basedenom fee tokens and their associated pool ids",
Long: strings.TrimSpace(
fmt.Sprintf(`Query the list of non-basedenom fee tokens and their associated pool ids
Example:
$ %s query txfees fee-tokens
`,
version.AppName,
),
),
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)

res, err := queryClient.FeeTokens(cmd.Context(), &types.QueryFeeTokensRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdGaugeIds takes the pool id and returns the matching gauge ids and durations
func GetCmdDenomPoolID() *cobra.Command {
cmd := &cobra.Command{
Use: "denom-pool-id",
Short: "Query the pool id associated with a specific whitelisted fee token",
Long: strings.TrimSpace(
fmt.Sprintf(`Query the pool id associated with a specific fee token
Example:
$ %s query txfees denom-pool-id [denom]
`,
version.AppName,
),
),
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)

res, err := queryClient.DenomPoolId(cmd.Context(), &types.QueryDenomPoolIdRequest{
Denom: args[0],
})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
return cmd
}

// GetCmdDistrInfo takes the pool id and returns the matching gauge ids and weights
func GetCmdBaseDenom() *cobra.Command {
cmd := &cobra.Command{
Use: "base-denom",
Short: "Query the base fee denom",
Long: strings.TrimSpace(
fmt.Sprintf(`Query the base fee denom.
Example:
$ %s query txfees base-denom
`,
version.AppName,
),
),
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)

res, err := queryClient.BaseDenom(cmd.Context(), &types.QueryBaseDenomRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading

0 comments on commit b6a5f4c

Please sign in to comment.