-
Notifications
You must be signed in to change notification settings - Fork 4.2k
x/mint: gRPC query service #6535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
162dfce
Added grpc for mint
atheeshp 0a41301
changed unused params
atheeshp 2a9fd2e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp 8dcc12e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp 73c3826
updated tests
atheeshp 9c24587
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp 80e66aa
removed empty query request
atheeshp 7fabfc5
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp eef42b0
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp c66d762
fixed lint issues
atheeshp 6917f82
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp e50ceda
review changes
atheeshp e8ba72c
Merge branch 'master' into atheesh/5921-grpc-x-mint
sahith-narahari 7a910db
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp 10f18ad
Merge branch 'atheesh/5921-grpc-x-mint' of github.com:cosmos/cosmos-s…
atheeshp 541f175
review changes
atheeshp 6680c5c
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp 5d45c36
migrated to use test suite
atheeshp 1868c5c
Update x/mint/keeper/grpc_query_test.go
fedekunze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,43 @@ | ||
| syntax = "proto3"; | ||
| package cosmos.mint; | ||
|
|
||
| import "gogoproto/gogo.proto"; | ||
| import "cosmos/mint/mint.proto"; | ||
|
|
||
| option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; | ||
|
|
||
| // Query provides defines the gRPC querier service | ||
| service Query { | ||
| // Params returns the total set of minting parameters. | ||
| rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {} | ||
|
|
||
| // Inflation returns the current minting inflation value. | ||
| rpc Inflation (QueryInflationRequest) returns (QueryInflationResponse) {} | ||
|
|
||
| // AnnualProvisions current minting annual provisions value. | ||
| rpc AnnualProvisions (QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) {} | ||
| } | ||
|
|
||
| // 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]; | ||
| } | ||
|
|
||
| // QueryInflationRequest is the request type for the Query/Inflation RPC method | ||
| message QueryInflationRequest { } | ||
|
|
||
| // QueryInflationResponse is the response type for the Query/Inflation RPC method | ||
| message QueryInflationResponse { | ||
| bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; | ||
| } | ||
|
|
||
| // QueryAnnualProvisionsRequest is the request type for the Query/AnnualProvisions RPC method | ||
| message QueryAnnualProvisionsRequest { } | ||
|
|
||
| // QueryAnnualProvisionsResponse is the response type for the Query/AnnualProvisions RPC method | ||
| message QueryAnnualProvisionsResponse { | ||
| bytes annual_provisions = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; | ||
| } |
This file contains hidden or 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,34 @@ | ||
| package keeper | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| "github.com/cosmos/cosmos-sdk/x/mint/types" | ||
| ) | ||
|
|
||
| var _ types.QueryServer = Keeper{} | ||
|
|
||
| // Params returns params of the mint module. | ||
| func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { | ||
| ctx := sdk.UnwrapSDKContext(c) | ||
| params := k.GetParams(ctx) | ||
|
|
||
| return &types.QueryParamsResponse{Params: params}, nil | ||
| } | ||
|
|
||
| // Inflation returns minter.Inflation of the mint module. | ||
| func (k Keeper) Inflation(c context.Context, _ *types.QueryInflationRequest) (*types.QueryInflationResponse, error) { | ||
| ctx := sdk.UnwrapSDKContext(c) | ||
| minter := k.GetMinter(ctx) | ||
|
|
||
| return &types.QueryInflationResponse{Inflation: minter.Inflation}, nil | ||
| } | ||
|
|
||
| // AnnualProvisions returns minter.AnnualProvisions of the mint module. | ||
| func (k Keeper) AnnualProvisions(c context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) { | ||
| ctx := sdk.UnwrapSDKContext(c) | ||
| minter := k.GetMinter(ctx) | ||
|
|
||
| return &types.QueryAnnualProvisionsResponse{AnnualProvisions: minter.AnnualProvisions}, nil | ||
| } |
This file contains hidden or 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,55 @@ | ||
| package keeper_test | ||
|
|
||
| import ( | ||
| gocontext "context" | ||
| "testing" | ||
|
|
||
| "github.com/cosmos/cosmos-sdk/baseapp" | ||
| "github.com/cosmos/cosmos-sdk/simapp" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| "github.com/cosmos/cosmos-sdk/x/mint/types" | ||
| "github.com/stretchr/testify/suite" | ||
| abci "github.com/tendermint/tendermint/abci/types" | ||
| ) | ||
|
|
||
| type MintTestSuite struct { | ||
| suite.Suite | ||
|
|
||
| app *simapp.SimApp | ||
| ctx sdk.Context | ||
| queryClient types.QueryClient | ||
| } | ||
|
|
||
| func (suite *MintTestSuite) SetupTest() { | ||
| app := simapp.Setup(false) | ||
| ctx := app.BaseApp.NewContext(false, abci.Header{}) | ||
|
|
||
| queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) | ||
| types.RegisterQueryServer(queryHelper, app.MintKeeper) | ||
| queryClient := types.NewQueryClient(queryHelper) | ||
|
|
||
| suite.app = app | ||
| suite.ctx = ctx | ||
|
|
||
| suite.queryClient = queryClient | ||
| } | ||
|
|
||
| func (suite *MintTestSuite) TestGRPCParams() { | ||
| app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient | ||
|
|
||
| params, err := queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) | ||
| suite.NoError(err) | ||
| suite.Equal(params.Params, app.MintKeeper.GetParams(ctx)) | ||
|
|
||
| inflation, err := queryClient.Inflation(gocontext.Background(), &types.QueryInflationRequest{}) | ||
| suite.NoError(err) | ||
| suite.Equal(inflation.Inflation, app.MintKeeper.GetMinter(ctx).Inflation) | ||
|
|
||
| annualProvisions, err := queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) | ||
| suite.NoError(err) | ||
| suite.Equal(annualProvisions.AnnualProvisions, app.MintKeeper.GetMinter(ctx).AnnualProvisions) | ||
| } | ||
|
|
||
| func TestMintTestSuite(t *testing.T) { | ||
| suite.Run(t, new(MintTestSuite)) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.