Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Oct 18, 2021
1 parent 63cc9ba commit e4ae67c
Show file tree
Hide file tree
Showing 16 changed files with 2,090 additions and 93 deletions.
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: 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
}
99 changes: 81 additions & 18 deletions x/txfees/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,99 @@
package cli

import (
"fmt"
"time"
"strconv"

"github.com/cosmos/cosmos-sdk/client/tx"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
// "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/osmosis-labs/osmosis/x/txfees/types"
)
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

var (
DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())
)

const (
flagPacketTimeoutTimestamp = "packet-timeout-timestamp"
"github.com/osmosis-labs/osmosis/x/txfees/types"
)


// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
func NewTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
Short: "txfees transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

// this line is used by starport scaffolding # 1
txCmd.AddCommand(
NewCmdSubmitUpdateFeeTokenProposal(),
)

return txCmd
}

func NewCmdSubmitUpdateFeeTokenProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "update-fee-token [denom] [poolId]",
Args: cobra.ExactArgs(2),
Short: "Submit an update to a fee token to be usable for tx fees",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

denom := args[0]
pool_id, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return err
}

feeToken := types.FeeToken{
Denom: denom,
PoolID: pool_id,
}

title, err := cmd.Flags().GetString(cli.FlagTitle)
if err != nil {
return err
}

description, err := cmd.Flags().GetString(cli.FlagDescription)
if err != nil {
return err
}

from := clientCtx.GetFromAddress()

depositStr, err := cmd.Flags().GetString(cli.FlagDeposit)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(depositStr)
if err != nil {
return err
}

content := types.NewUpdateFeeTokenProposal(title, description, feeToken)

msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

if err = msg.ValidateBasic(); err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
cmd.Flags().String(cli.FlagDescription, "", "description of proposal")
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
cmd.MarkFlagRequired(cli.FlagTitle)
cmd.MarkFlagRequired(cli.FlagDescription)

return cmd
return cmd
}
3 changes: 1 addition & 2 deletions x/txfees/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
MethodGet = "GET"
MethodGet = "GET"
)

// RegisterRoutes registers txfees-related REST handlers to a router
Expand All @@ -23,4 +23,3 @@ func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
func registerTxHandlers(clientCtx client.Context, r *mux.Router) {
// this line is used by starport scaffolding # 4
}

Loading

0 comments on commit e4ae67c

Please sign in to comment.