-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gasfree params querying, general cleanup
- Loading branch information
1 parent
eaffc52
commit 784a083
Showing
10 changed files
with
815 additions
and
20 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
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,25 @@ | ||
syntax = "proto3"; | ||
package althea.gasfree.v1; | ||
|
||
import "google/api/annotations.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "althea/gasfree/v1/genesis.proto"; | ||
|
||
option go_package = "github.com/althea-net/althea-L1/x/gasfree/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params retrieves the total set of onboarding parameters. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/althea/gasfree/v1/params"; | ||
} | ||
} | ||
|
||
// 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 defines the parameters of the module. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
} |
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,53 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/althea-net/althea-L1/x/gasfree/types" | ||
) | ||
|
||
// GetQueryCmd bundles all the query subcmds together so they appear under the `query` or `q` subcommand | ||
func GetQueryCmd() *cobra.Command { | ||
// nolint: exhaustruct | ||
gasfreeQueryCmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: "Querying commands for the gasfree module", | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
gasfreeQueryCmd.AddCommand([]*cobra.Command{ | ||
CmdQueryParams(), | ||
}...) | ||
|
||
return gasfreeQueryCmd | ||
} | ||
|
||
// CmdQueryParams fetches the current microtx params | ||
func CmdQueryParams() *cobra.Command { | ||
// nolint: exhaustruct | ||
cmd := &cobra.Command{ | ||
Use: "params", | ||
Args: cobra.NoArgs, | ||
Short: "Query gasfree params", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(&res.Params) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
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,22 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/althea-net/althea-L1/x/gasfree/types" | ||
) | ||
|
||
// nolint: exhaustruct | ||
// Enforce via type assertion that the Keeper functions as a query server | ||
var _ types.QueryServer = Keeper{} | ||
|
||
// Params queries the params of the microtx module | ||
func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { | ||
p, err := k.GetParamsIfSet(sdk.UnwrapSDKContext(c)) | ||
if err != nil { | ||
return nil, err // Force an empty response on error | ||
} | ||
return &types.QueryParamsResponse{Params: p}, nil | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.