mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
Savings module: deposit querier (#1193)
* module files * proto types * types and generated proto types * keeper * client scaffold * add savings module to app * remove placeholder types file * implement rest and add to module * update proto types * validation for supported denoms * generate updates proto types * update comments * update comments * remove unused imports from proto files * regenerate proto files * update proto types * client * deposit type and generated proto types * deposit keeper methods + tests * update savings module file * update app.go + test common * query proto types * query types + generated proto types * keeper logic for deposits queries * cli/rest querier updates * remove abci * remove refs to other modules * remove endblocker call * genesis init test for module account * update genesis test with params * add get/set params test * fix up keeper test * use params getter * simplify if/else statement * remove querier.go and rest/query * update query deposit description * remove legacy querier * register querier * revisions
This commit is contained in:
parent
26e350945e
commit
f0fa2e1253
@ -4,6 +4,8 @@ package kava.savings.v1beta1;
|
|||||||
import "kava/savings/v1beta1/store.proto";
|
import "kava/savings/v1beta1/store.proto";
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
|
import "cosmos_proto/cosmos.proto";
|
||||||
|
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||||
|
|
||||||
option go_package = "github.com/kava-labs/kava/x/savings/types";
|
option go_package = "github.com/kava-labs/kava/x/savings/types";
|
||||||
|
|
||||||
@ -13,6 +15,12 @@ service Query {
|
|||||||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
|
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
|
||||||
option (google.api.http).get = "/kava/savings/v1beta1/params";
|
option (google.api.http).get = "/kava/savings/v1beta1/params";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deposits queries savings deposits.
|
||||||
|
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
|
||||||
|
option (google.api.http).get = "/kava/savings/v1beta1/deposits";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryParamsRequest defines the request type for querying x/savings
|
// QueryParamsRequest defines the request type for querying x/savings
|
||||||
@ -26,3 +34,20 @@ message QueryParamsResponse {
|
|||||||
|
|
||||||
Params params = 1 [(gogoproto.nullable) = false];
|
Params params = 1 [(gogoproto.nullable) = false];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryDepositsRequest defines the request type for querying x/savings
|
||||||
|
// deposits.
|
||||||
|
message QueryDepositsRequest {
|
||||||
|
string denom = 1;
|
||||||
|
string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||||
|
|
||||||
|
cosmos.base.query.v1beta1.PageRequest pagination = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDepositsResponse defines the response type for querying x/savings
|
||||||
|
// deposits.
|
||||||
|
message QueryDepositsResponse {
|
||||||
|
repeated Deposit deposits = 1 [(gogoproto.castrepeated) = "Deposits", (gogoproto.nullable) = false];
|
||||||
|
|
||||||
|
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||||
|
}
|
||||||
|
@ -17,7 +17,8 @@ message Params {
|
|||||||
message Deposit {
|
message Deposit {
|
||||||
string depositor = 1 [
|
string depositor = 1 [
|
||||||
(cosmos_proto.scalar) = "cosmos.AddressBytes",
|
(cosmos_proto.scalar) = "cosmos.AddressBytes",
|
||||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
|
||||||
|
];
|
||||||
|
|
||||||
repeated cosmos.base.v1beta1.Coin amount = 2
|
repeated cosmos.base.v1beta1.Coin amount = 2
|
||||||
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
|
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
|
||||||
|
@ -2,15 +2,24 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/savings/types"
|
"github.com/kava-labs/kava/x/savings/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// flags for cli queries
|
||||||
|
const (
|
||||||
|
flagDenom = "denom"
|
||||||
|
flagOwner = "owner"
|
||||||
|
)
|
||||||
|
|
||||||
// GetQueryCmd returns the cli query commands for this module
|
// GetQueryCmd returns the cli query commands for this module
|
||||||
func GetQueryCmd() *cobra.Command {
|
func GetQueryCmd() *cobra.Command {
|
||||||
savingsQueryCmd := &cobra.Command{
|
savingsQueryCmd := &cobra.Command{
|
||||||
@ -23,6 +32,7 @@ func GetQueryCmd() *cobra.Command {
|
|||||||
|
|
||||||
cmds := []*cobra.Command{
|
cmds := []*cobra.Command{
|
||||||
GetCmdQueryParams(),
|
GetCmdQueryParams(),
|
||||||
|
queryDepositsCmd(),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
@ -58,3 +68,65 @@ func GetCmdQueryParams() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func queryDepositsCmd() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "deposits",
|
||||||
|
Short: "query savings module deposits with optional filters",
|
||||||
|
Long: "query for all savings module deposits or a specific deposit using flags",
|
||||||
|
Example: fmt.Sprintf(`%[1]s q %[2]s deposits
|
||||||
|
%[1]s q %[2]s deposits --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --denom bnb
|
||||||
|
%[1]s q %[2]s deposits --denom ukava
|
||||||
|
%[1]s q %[2]s deposits --denom btcb`, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
ownerBech, err := cmd.Flags().GetString(flagOwner)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
denom, err := cmd.Flags().GetString(flagDenom)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
req := &types.QueryDepositsRequest{
|
||||||
|
Denom: denom,
|
||||||
|
Pagination: pageReq,
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ownerBech) != 0 {
|
||||||
|
depositOwner, err := sdk.AccAddressFromBech32(ownerBech)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Owner = depositOwner.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
queryClient := types.NewQueryClient(clientCtx)
|
||||||
|
|
||||||
|
res, err := queryClient.Deposits(context.Background(), req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientCtx.PrintProto(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddPaginationFlagsToCmd(cmd, "deposits")
|
||||||
|
|
||||||
|
cmd.Flags().String(flagOwner, "", "(optional) filter for deposits by owner address")
|
||||||
|
cmd.Flags().String(flagDenom, "", "(optional) filter for deposits by denom")
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package rest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/savings/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// define routes that get registered by the main application
|
|
||||||
func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
|
|
||||||
r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET")
|
|
||||||
}
|
|
||||||
|
|
||||||
func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// Parse the query height
|
|
||||||
cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryGetParams), nil)
|
|
||||||
if err != nil {
|
|
||||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cliCtx = cliCtx.WithHeight(height)
|
|
||||||
rest.PostProcessResponse(w, cliCtx, res)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package rest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RegisterRoutes - Central function to define routes that get registered by the main application
|
|
||||||
func RegisterRoutes(cliCtx client.Context, r *mux.Router) {
|
|
||||||
registerQueryRoutes(cliCtx, r)
|
|
||||||
registerTxRoutes(cliCtx, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostCreateDepositReq defines the properties of a deposit create request's body
|
|
||||||
type PostCreateDepositReq struct {
|
|
||||||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
|
|
||||||
From sdk.AccAddress `json:"from" yaml:"from"`
|
|
||||||
Amount sdk.Coins `json:"amount" yaml:"amount"`
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package rest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/savings/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func registerTxRoutes(cliCtx client.Context, r *mux.Router) {
|
|
||||||
r.HandleFunc(fmt.Sprintf("/%s/deposit", types.ModuleName), postDepositHandlerFn(cliCtx)).Methods("POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
func postDepositHandlerFn(cliCtx client.Context) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// Decode POST request body
|
|
||||||
var req PostCreateDepositReq
|
|
||||||
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.BaseReq = req.BaseReq.Sanitize()
|
|
||||||
if !req.BaseReq.ValidateBasic(w) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := types.NewMsgDeposit(req.From, req.Amount)
|
|
||||||
if err := msg.ValidateBasic(); err != nil {
|
|
||||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, &msg)
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,10 @@ import (
|
|||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/savings/types"
|
"github.com/kava-labs/kava/x/savings/types"
|
||||||
)
|
)
|
||||||
@ -33,3 +36,70 @@ func (s queryServer) Params(c context.Context, req *types.QueryParamsRequest) (*
|
|||||||
|
|
||||||
return &types.QueryParamsResponse{Params: params}, nil
|
return &types.QueryParamsResponse{Params: params}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s queryServer) Deposits(ctx context.Context, req *types.QueryDepositsRequest) (*types.QueryDepositsResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "empty request")
|
||||||
|
}
|
||||||
|
|
||||||
|
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
||||||
|
|
||||||
|
hasDenom := len(req.Denom) > 0
|
||||||
|
hasOwner := len(req.Owner) > 0
|
||||||
|
|
||||||
|
var owner sdk.AccAddress
|
||||||
|
var err error
|
||||||
|
if hasOwner {
|
||||||
|
owner, err = sdk.AccAddressFromBech32(req.Owner)
|
||||||
|
if err != nil {
|
||||||
|
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var deposits types.Deposits
|
||||||
|
switch {
|
||||||
|
case hasOwner && hasDenom:
|
||||||
|
deposit, found := s.keeper.GetDeposit(sdkCtx, owner)
|
||||||
|
if found {
|
||||||
|
for _, coin := range deposit.Amount {
|
||||||
|
if coin.Denom == req.Denom {
|
||||||
|
deposits = append(deposits, deposit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case hasOwner:
|
||||||
|
deposit, found := s.keeper.GetDeposit(sdkCtx, owner)
|
||||||
|
if found {
|
||||||
|
deposits = append(deposits, deposit)
|
||||||
|
}
|
||||||
|
case hasDenom:
|
||||||
|
s.keeper.IterateDeposits(sdkCtx, func(deposit types.Deposit) (stop bool) {
|
||||||
|
if deposit.Amount.AmountOf(req.Denom).IsPositive() {
|
||||||
|
deposits = append(deposits, deposit)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
s.keeper.IterateDeposits(sdkCtx, func(deposit types.Deposit) (stop bool) {
|
||||||
|
deposits = append(deposits, deposit)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
page, limit, err := query.ParsePagination(req.Pagination)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
start, end := client.Paginate(len(deposits), page, limit, 100)
|
||||||
|
if start < 0 || end < 0 {
|
||||||
|
deposits = types.Deposits{}
|
||||||
|
} else {
|
||||||
|
deposits = deposits[start:end]
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.QueryDepositsResponse{
|
||||||
|
Deposits: deposits,
|
||||||
|
Pagination: nil,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
198
x/savings/keeper/grpcquery_test.go
Normal file
198
x/savings/keeper/grpcquery_test.go
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
tmprototypes "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
|
|
||||||
|
"github.com/kava-labs/kava/app"
|
||||||
|
"github.com/kava-labs/kava/x/savings/keeper"
|
||||||
|
"github.com/kava-labs/kava/x/savings/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type grpcQueryTestSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
|
||||||
|
tApp app.TestApp
|
||||||
|
ctx sdk.Context
|
||||||
|
keeper keeper.Keeper
|
||||||
|
queryServer types.QueryServer
|
||||||
|
addrs []sdk.AccAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *grpcQueryTestSuite) SetupTest() {
|
||||||
|
suite.tApp = app.NewTestApp()
|
||||||
|
_, addrs := app.GeneratePrivKeyAddressPairs(2)
|
||||||
|
|
||||||
|
suite.addrs = addrs
|
||||||
|
|
||||||
|
suite.ctx = suite.tApp.NewContext(true, tmprototypes.Header{}).
|
||||||
|
WithBlockTime(time.Now().UTC())
|
||||||
|
suite.keeper = suite.tApp.GetSavingsKeeper()
|
||||||
|
suite.queryServer = keeper.NewQueryServerImpl(suite.keeper)
|
||||||
|
|
||||||
|
err := suite.tApp.FundModuleAccount(
|
||||||
|
suite.ctx,
|
||||||
|
types.ModuleAccountName,
|
||||||
|
cs(
|
||||||
|
c("usdx", 10000000000),
|
||||||
|
c("busd", 10000000000),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
savingsGenesis := types.GenesisState{
|
||||||
|
Params: types.NewParams([]string{"bnb", "busd"}),
|
||||||
|
}
|
||||||
|
savingsGenState := app.GenesisState{types.ModuleName: suite.tApp.AppCodec().MustMarshalJSON(&savingsGenesis)}
|
||||||
|
|
||||||
|
suite.tApp.InitializeFromGenesisStates(
|
||||||
|
savingsGenState,
|
||||||
|
app.NewFundedGenStateWithSameCoins(
|
||||||
|
suite.tApp.AppCodec(),
|
||||||
|
cs(
|
||||||
|
c("bnb", 10000000000),
|
||||||
|
c("busd", 20000000000),
|
||||||
|
),
|
||||||
|
addrs,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *grpcQueryTestSuite) TestGrpcQueryParams() {
|
||||||
|
res, err := suite.queryServer.Params(sdk.WrapSDKContext(suite.ctx), &types.QueryParamsRequest{})
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
|
var expected types.GenesisState
|
||||||
|
savingsGenesis := types.GenesisState{
|
||||||
|
Params: types.NewParams([]string{"bnb", "busd"}),
|
||||||
|
}
|
||||||
|
savingsGenState := app.GenesisState{types.ModuleName: suite.tApp.AppCodec().MustMarshalJSON(&savingsGenesis)}
|
||||||
|
suite.tApp.AppCodec().MustUnmarshalJSON(savingsGenState[types.ModuleName], &expected)
|
||||||
|
|
||||||
|
suite.Equal(expected.Params, res.Params, "params should equal test genesis state")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *grpcQueryTestSuite) TestGrpcQueryDeposits() {
|
||||||
|
suite.addDeposits()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
giveName string
|
||||||
|
giveRequest *types.QueryDepositsRequest
|
||||||
|
wantDepositCounts int
|
||||||
|
shouldError bool
|
||||||
|
errorSubstr string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty query",
|
||||||
|
&types.QueryDepositsRequest{},
|
||||||
|
2,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"owner",
|
||||||
|
&types.QueryDepositsRequest{
|
||||||
|
Owner: suite.addrs[0].String(),
|
||||||
|
},
|
||||||
|
// Excludes the second address
|
||||||
|
1,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"invalid owner",
|
||||||
|
&types.QueryDepositsRequest{
|
||||||
|
Owner: "invalid address",
|
||||||
|
},
|
||||||
|
// No deposits
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
"decoding bech32 failed",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"owner and denom",
|
||||||
|
&types.QueryDepositsRequest{
|
||||||
|
Owner: suite.addrs[0].String(),
|
||||||
|
Denom: "bnb",
|
||||||
|
},
|
||||||
|
// Only the first one
|
||||||
|
1,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"owner and invalid denom empty response",
|
||||||
|
&types.QueryDepositsRequest{
|
||||||
|
Owner: suite.addrs[0].String(),
|
||||||
|
Denom: "invalid denom",
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"denom",
|
||||||
|
&types.QueryDepositsRequest{
|
||||||
|
Denom: "bnb",
|
||||||
|
},
|
||||||
|
2,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
suite.Run(tt.giveName, func() {
|
||||||
|
res, err := suite.queryServer.Deposits(sdk.WrapSDKContext(suite.ctx), tt.giveRequest)
|
||||||
|
|
||||||
|
if tt.shouldError {
|
||||||
|
suite.Error(err)
|
||||||
|
suite.Contains(err.Error(), tt.errorSubstr)
|
||||||
|
} else {
|
||||||
|
suite.NoError(err)
|
||||||
|
suite.Equal(tt.wantDepositCounts, len(res.Deposits))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *grpcQueryTestSuite) addDeposits() {
|
||||||
|
deposits := []struct {
|
||||||
|
Address sdk.AccAddress
|
||||||
|
Coins sdk.Coins
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
suite.addrs[0],
|
||||||
|
cs(c("bnb", 100000000)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
suite.addrs[1],
|
||||||
|
cs(c("bnb", 20000000)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
suite.addrs[0],
|
||||||
|
cs(c("busd", 20000000)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
suite.addrs[0],
|
||||||
|
cs(c("busd", 8000000)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, dep := range deposits {
|
||||||
|
suite.NotPanics(func() {
|
||||||
|
err := suite.keeper.Deposit(suite.ctx, dep.Address, dep.Coins)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGrpcQueryTestSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(grpcQueryTestSuite))
|
||||||
|
}
|
@ -1,36 +0,0 @@
|
|||||||
package keeper
|
|
||||||
|
|
||||||
import (
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/savings/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewQuerier is the module level router for state queries
|
|
||||||
func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
||||||
return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) {
|
|
||||||
switch path[0] {
|
|
||||||
case types.QueryGetParams:
|
|
||||||
return queryGetParams(ctx, req, keeper, legacyQuerierCdc)
|
|
||||||
default:
|
|
||||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint", types.ModuleName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// query params in the pricefeed store
|
|
||||||
func queryGetParams(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
|
||||||
params := keeper.GetParams(ctx)
|
|
||||||
|
|
||||||
// Encode results
|
|
||||||
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, params)
|
|
||||||
if err != nil {
|
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
|
||||||
}
|
|
||||||
return bz, nil
|
|
||||||
}
|
|
@ -18,7 +18,6 @@ import (
|
|||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/savings/client/cli"
|
"github.com/kava-labs/kava/x/savings/client/cli"
|
||||||
"github.com/kava-labs/kava/x/savings/client/rest"
|
|
||||||
"github.com/kava-labs/kava/x/savings/keeper"
|
"github.com/kava-labs/kava/x/savings/keeper"
|
||||||
"github.com/kava-labs/kava/x/savings/types"
|
"github.com/kava-labs/kava/x/savings/types"
|
||||||
)
|
)
|
||||||
@ -65,7 +64,7 @@ func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry
|
|||||||
|
|
||||||
// RegisterRESTRoutes registers REST routes for the module.
|
// RegisterRESTRoutes registers REST routes for the module.
|
||||||
func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||||
rest.RegisterRoutes(clientCtx, rtr)
|
// intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module.
|
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module.
|
||||||
@ -126,7 +125,7 @@ func (AppModule) QuerierRoute() string {
|
|||||||
|
|
||||||
// LegacyQuerierHandler returns no sdk.Querier.
|
// LegacyQuerierHandler returns no sdk.Querier.
|
||||||
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
||||||
return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||||
@ -136,9 +135,8 @@ func (AppModule) ConsensusVersion() uint64 {
|
|||||||
|
|
||||||
// RegisterServices registers module services.
|
// RegisterServices registers module services.
|
||||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||||
// TODO:
|
|
||||||
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
||||||
// types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
|
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper))
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitGenesis module init-genesis
|
// InitGenesis module init-genesis
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
const (
|
|
||||||
// QueryGetParams command for params query
|
|
||||||
QueryGetParams = "parameters"
|
|
||||||
)
|
|
@ -6,6 +6,8 @@ package types
|
|||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
|
_ "github.com/cosmos/cosmos-proto"
|
||||||
|
query "github.com/cosmos/cosmos-sdk/types/query"
|
||||||
_ "github.com/gogo/protobuf/gogoproto"
|
_ "github.com/gogo/protobuf/gogoproto"
|
||||||
grpc1 "github.com/gogo/protobuf/grpc"
|
grpc1 "github.com/gogo/protobuf/grpc"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
proto "github.com/gogo/protobuf/proto"
|
||||||
@ -106,34 +108,165 @@ func (m *QueryParamsResponse) XXX_DiscardUnknown() {
|
|||||||
|
|
||||||
var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
|
var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
|
// QueryDepositsRequest defines the request type for querying x/savings
|
||||||
|
// deposits.
|
||||||
|
type QueryDepositsRequest struct {
|
||||||
|
Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
|
||||||
|
Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||||
|
Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) Reset() { *m = QueryDepositsRequest{} }
|
||||||
|
func (m *QueryDepositsRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*QueryDepositsRequest) ProtoMessage() {}
|
||||||
|
func (*QueryDepositsRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_f78c91efc5db144f, []int{2}
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_QueryDepositsRequest.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_QueryDepositsRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsRequest) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_QueryDepositsRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_QueryDepositsRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) GetDenom() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Denom
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) GetOwner() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Owner
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) GetPagination() *query.PageRequest {
|
||||||
|
if m != nil {
|
||||||
|
return m.Pagination
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDepositsResponse defines the response type for querying x/savings
|
||||||
|
// deposits.
|
||||||
|
type QueryDepositsResponse struct {
|
||||||
|
Deposits Deposits `protobuf:"bytes,1,rep,name=deposits,proto3,castrepeated=Deposits" json:"deposits"`
|
||||||
|
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) Reset() { *m = QueryDepositsResponse{} }
|
||||||
|
func (m *QueryDepositsResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*QueryDepositsResponse) ProtoMessage() {}
|
||||||
|
func (*QueryDepositsResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_f78c91efc5db144f, []int{3}
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsResponse) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_QueryDepositsResponse.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsResponse) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_QueryDepositsResponse.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsResponse) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsResponse) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_QueryDepositsResponse.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_QueryDepositsResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) GetDeposits() Deposits {
|
||||||
|
if m != nil {
|
||||||
|
return m.Deposits
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) GetPagination() *query.PageResponse {
|
||||||
|
if m != nil {
|
||||||
|
return m.Pagination
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*QueryParamsRequest)(nil), "kava.savings.v1beta1.QueryParamsRequest")
|
proto.RegisterType((*QueryParamsRequest)(nil), "kava.savings.v1beta1.QueryParamsRequest")
|
||||||
proto.RegisterType((*QueryParamsResponse)(nil), "kava.savings.v1beta1.QueryParamsResponse")
|
proto.RegisterType((*QueryParamsResponse)(nil), "kava.savings.v1beta1.QueryParamsResponse")
|
||||||
|
proto.RegisterType((*QueryDepositsRequest)(nil), "kava.savings.v1beta1.QueryDepositsRequest")
|
||||||
|
proto.RegisterType((*QueryDepositsResponse)(nil), "kava.savings.v1beta1.QueryDepositsResponse")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("kava/savings/v1beta1/query.proto", fileDescriptor_f78c91efc5db144f) }
|
func init() { proto.RegisterFile("kava/savings/v1beta1/query.proto", fileDescriptor_f78c91efc5db144f) }
|
||||||
|
|
||||||
var fileDescriptor_f78c91efc5db144f = []byte{
|
var fileDescriptor_f78c91efc5db144f = []byte{
|
||||||
// 290 bytes of a gzipped FileDescriptorProto
|
// 499 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x4e, 0x2c, 0x4b,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x3f, 0x6f, 0x13, 0x31,
|
||||||
0xd4, 0x2f, 0x4e, 0x2c, 0xcb, 0xcc, 0x4b, 0x2f, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34,
|
0x18, 0xc6, 0xcf, 0x69, 0x13, 0x15, 0x77, 0x41, 0xe6, 0x90, 0x8e, 0x28, 0x5c, 0xa2, 0x13, 0x2a,
|
||||||
0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x01, 0xa9,
|
0x69, 0x51, 0x7d, 0x6a, 0xd8, 0xba, 0x11, 0x10, 0x0c, 0x2c, 0x70, 0x0c, 0x48, 0x2c, 0xc8, 0xd7,
|
||||||
0xd0, 0x83, 0xaa, 0xd0, 0x83, 0xaa, 0x90, 0xc2, 0xae, 0xaf, 0xb8, 0x24, 0xbf, 0x28, 0x15, 0xa2,
|
0x58, 0xe6, 0x44, 0x63, 0x5f, 0xef, 0x75, 0x02, 0x5d, 0x61, 0x41, 0x62, 0x41, 0x62, 0x64, 0x61,
|
||||||
0x4f, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0xa0, 0xa2, 0x32, 0xe9, 0xf9,
|
0x60, 0x42, 0x62, 0xe3, 0x43, 0x74, 0xac, 0x60, 0x61, 0x02, 0x94, 0xf0, 0x41, 0xd0, 0xd9, 0xee,
|
||||||
0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25,
|
0xf5, 0x0f, 0x27, 0x9a, 0xed, 0xfc, 0xfa, 0x79, 0x1e, 0xff, 0xde, 0xd7, 0x3e, 0xdc, 0x7b, 0xce,
|
||||||
0x99, 0xf9, 0x79, 0xc5, 0x10, 0x59, 0x25, 0x11, 0x2e, 0xa1, 0x40, 0x90, 0xd5, 0x01, 0x89, 0x45,
|
0xa6, 0x2c, 0x06, 0x36, 0xcd, 0xa4, 0x80, 0x78, 0xba, 0x95, 0x72, 0xcd, 0xb6, 0xe2, 0xbd, 0x09,
|
||||||
0x89, 0xb9, 0xc5, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0xe1, 0x5c, 0xc2, 0x28, 0xa2,
|
0x2f, 0xf6, 0x69, 0x5e, 0x28, 0xad, 0x88, 0x5f, 0x2a, 0xa8, 0x53, 0x50, 0xa7, 0x68, 0xd7, 0xfb,
|
||||||
0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x56, 0x5c, 0x6c, 0x05, 0x60, 0x11, 0x09, 0x46, 0x05,
|
0x40, 0xab, 0x82, 0x5b, 0x5f, 0xdb, 0x17, 0x4a, 0x28, 0xf3, 0x19, 0x97, 0x5f, 0xae, 0xda, 0x11,
|
||||||
0x46, 0x0d, 0x6e, 0x23, 0x19, 0x3d, 0x6c, 0x2e, 0xd5, 0x83, 0xe8, 0x72, 0x62, 0x39, 0x71, 0x4f,
|
0x4a, 0x89, 0x5d, 0x1e, 0xb3, 0x3c, 0x8b, 0x99, 0x94, 0x4a, 0x33, 0x9d, 0x29, 0x09, 0x6e, 0xf7,
|
||||||
0x9e, 0x21, 0x08, 0xaa, 0xc3, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x51, 0x2f, 0x23, 0x17, 0x2b,
|
0xca, 0x8e, 0x82, 0xb1, 0x82, 0xa7, 0xd6, 0x66, 0x17, 0x6e, 0x6b, 0xc3, 0xae, 0xe2, 0x94, 0x01,
|
||||||
0xd8, 0x64, 0xa1, 0x66, 0x46, 0x2e, 0x36, 0x88, 0x42, 0x21, 0x0d, 0xec, 0xc6, 0x60, 0xba, 0x4b,
|
0xb7, 0x7c, 0xd5, 0xa9, 0x39, 0x13, 0x99, 0x34, 0x39, 0x56, 0x1b, 0xf9, 0x98, 0x3c, 0x2c, 0x15,
|
||||||
0x4a, 0x93, 0x08, 0x95, 0x10, 0xb7, 0x2a, 0xa9, 0x34, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x4e, 0x48,
|
0x0f, 0x58, 0xc1, 0xc6, 0x90, 0xf0, 0xbd, 0x09, 0x07, 0x1d, 0x3d, 0xc6, 0x97, 0x4e, 0x55, 0x21,
|
||||||
0x46, 0x1f, 0x6b, 0xb8, 0x41, 0x5c, 0xe5, 0xe4, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72,
|
0x57, 0x12, 0x38, 0xd9, 0xc6, 0xad, 0xdc, 0x54, 0x02, 0xd4, 0x43, 0xfd, 0xd5, 0x41, 0x87, 0xd6,
|
||||||
0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7,
|
0x35, 0x4c, 0xad, 0x6b, 0xb8, 0x7c, 0xf0, 0xb3, 0xeb, 0x25, 0xce, 0xb1, 0xbd, 0xfc, 0xe6, 0x63,
|
||||||
0x72, 0x0c, 0x51, 0x9a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0x60, 0x13,
|
0xd7, 0x8b, 0x3e, 0x21, 0xec, 0x9b, 0xe4, 0x3b, 0x3c, 0x57, 0x90, 0xe9, 0xa3, 0x13, 0x89, 0x8f,
|
||||||
0x74, 0x73, 0x12, 0x93, 0x8a, 0x21, 0x66, 0x55, 0xc0, 0x4d, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e,
|
0x9b, 0x23, 0x2e, 0xd5, 0xd8, 0x24, 0x5f, 0x48, 0xec, 0x82, 0x50, 0xdc, 0x54, 0x2f, 0x24, 0x2f,
|
||||||
0x62, 0x03, 0x07, 0xa5, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x6f, 0x18, 0xf9, 0xda, 0x01,
|
0x82, 0x46, 0x59, 0x1d, 0x06, 0xdf, 0xbe, 0x6e, 0xfa, 0xae, 0xd5, 0x5b, 0xa3, 0x51, 0xc1, 0x01,
|
||||||
0x00, 0x00,
|
0x1e, 0xe9, 0x22, 0x93, 0x22, 0xb1, 0x32, 0x72, 0x17, 0xe3, 0xe3, 0x0e, 0x83, 0x25, 0x03, 0xb9,
|
||||||
|
0x46, 0x9d, 0xa3, 0x1c, 0x07, 0xb5, 0xd7, 0x75, 0x4c, 0x2a, 0xb8, 0x23, 0x48, 0x4e, 0x38, 0xa3,
|
||||||
|
0x2f, 0x08, 0x5f, 0x3e, 0x83, 0xe9, 0x46, 0x70, 0x1f, 0xaf, 0x8c, 0x5c, 0x2d, 0x40, 0xbd, 0xa5,
|
||||||
|
0xfe, 0xea, 0xe0, 0x6a, 0xfd, 0x10, 0x9c, 0x73, 0x78, 0xb1, 0x9c, 0xc2, 0xe7, 0x5f, 0xdd, 0x95,
|
||||||
|
0x2a, 0xaa, 0x0a, 0x20, 0xf7, 0x4e, 0xe1, 0x36, 0x0c, 0xee, 0xf5, 0x73, 0x71, 0x2d, 0xc9, 0x49,
|
||||||
|
0xde, 0xc1, 0x87, 0x06, 0x6e, 0x1a, 0x5e, 0xf2, 0x1a, 0xe1, 0x96, 0x9d, 0x3f, 0xe9, 0xd7, 0x83,
|
||||||
|
0xfd, 0x7b, 0xdd, 0xed, 0xf5, 0x05, 0x94, 0xf6, 0xd4, 0xe8, 0xda, 0xab, 0xef, 0x7f, 0xde, 0x37,
|
||||||
|
0x42, 0xd2, 0x89, 0x6b, 0x5f, 0xb5, 0xbd, 0x6c, 0xf2, 0x16, 0xe1, 0xaa, 0x5f, 0xb2, 0xf1, 0x9f,
|
||||||
|
0xf4, 0x33, 0xcf, 0xa0, 0x7d, 0x63, 0x21, 0xad, 0x63, 0x59, 0x33, 0x2c, 0x3d, 0x12, 0xd6, 0xb3,
|
||||||
|
0x1c, 0x8d, 0x79, 0x78, 0xfb, 0x60, 0x16, 0xa2, 0xc3, 0x59, 0x88, 0x7e, 0xcf, 0x42, 0xf4, 0x6e,
|
||||||
|
0x1e, 0x7a, 0x87, 0xf3, 0xd0, 0xfb, 0x31, 0x0f, 0xbd, 0x27, 0xeb, 0x22, 0xd3, 0xcf, 0x26, 0x29,
|
||||||
|
0xdd, 0x51, 0x63, 0x93, 0xb1, 0xb9, 0xcb, 0x52, 0xb0, 0x69, 0x2f, 0xab, 0x3c, 0xbd, 0x9f, 0x73,
|
||||||
|
0x48, 0x5b, 0xe6, 0x7f, 0xb9, 0xf9, 0x37, 0x00, 0x00, 0xff, 0xff, 0x39, 0xd3, 0xcd, 0xf1, 0x06,
|
||||||
|
0x04, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
@ -150,6 +283,8 @@ const _ = grpc.SupportPackageIsVersion4
|
|||||||
type QueryClient interface {
|
type QueryClient interface {
|
||||||
// Params queries all parameters of the savings module.
|
// Params queries all parameters of the savings module.
|
||||||
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
||||||
|
// Deposits queries savings deposits.
|
||||||
|
Deposits(ctx context.Context, in *QueryDepositsRequest, opts ...grpc.CallOption) (*QueryDepositsResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type queryClient struct {
|
type queryClient struct {
|
||||||
@ -169,10 +304,21 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts .
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *queryClient) Deposits(ctx context.Context, in *QueryDepositsRequest, opts ...grpc.CallOption) (*QueryDepositsResponse, error) {
|
||||||
|
out := new(QueryDepositsResponse)
|
||||||
|
err := c.cc.Invoke(ctx, "/kava.savings.v1beta1.Query/Deposits", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// QueryServer is the server API for Query service.
|
// QueryServer is the server API for Query service.
|
||||||
type QueryServer interface {
|
type QueryServer interface {
|
||||||
// Params queries all parameters of the savings module.
|
// Params queries all parameters of the savings module.
|
||||||
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
|
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
|
||||||
|
// Deposits queries savings deposits.
|
||||||
|
Deposits(context.Context, *QueryDepositsRequest) (*QueryDepositsResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
|
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
|
||||||
@ -182,6 +328,9 @@ type UnimplementedQueryServer struct {
|
|||||||
func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
|
func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
|
||||||
}
|
}
|
||||||
|
func (*UnimplementedQueryServer) Deposits(ctx context.Context, req *QueryDepositsRequest) (*QueryDepositsResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Deposits not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
|
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
|
||||||
s.RegisterService(&_Query_serviceDesc, srv)
|
s.RegisterService(&_Query_serviceDesc, srv)
|
||||||
@ -205,6 +354,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Query_Deposits_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(QueryDepositsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(QueryServer).Deposits(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/kava.savings.v1beta1.Query/Deposits",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(QueryServer).Deposits(ctx, req.(*QueryDepositsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
var _Query_serviceDesc = grpc.ServiceDesc{
|
var _Query_serviceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "kava.savings.v1beta1.Query",
|
ServiceName: "kava.savings.v1beta1.Query",
|
||||||
HandlerType: (*QueryServer)(nil),
|
HandlerType: (*QueryServer)(nil),
|
||||||
@ -213,6 +380,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "Params",
|
MethodName: "Params",
|
||||||
Handler: _Query_Params_Handler,
|
Handler: _Query_Params_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Deposits",
|
||||||
|
Handler: _Query_Deposits_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "kava/savings/v1beta1/query.proto",
|
Metadata: "kava/savings/v1beta1/query.proto",
|
||||||
@ -274,6 +445,104 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if m.Pagination != nil {
|
||||||
|
{
|
||||||
|
size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintQuery(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x1a
|
||||||
|
}
|
||||||
|
if len(m.Owner) > 0 {
|
||||||
|
i -= len(m.Owner)
|
||||||
|
copy(dAtA[i:], m.Owner)
|
||||||
|
i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
}
|
||||||
|
if len(m.Denom) > 0 {
|
||||||
|
i -= len(m.Denom)
|
||||||
|
copy(dAtA[i:], m.Denom)
|
||||||
|
i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if m.Pagination != nil {
|
||||||
|
{
|
||||||
|
size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintQuery(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
}
|
||||||
|
if len(m.Deposits) > 0 {
|
||||||
|
for iNdEx := len(m.Deposits) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
|
{
|
||||||
|
size, err := m.Deposits[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintQuery(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
|
||||||
offset -= sovQuery(v)
|
offset -= sovQuery(v)
|
||||||
base := offset
|
base := offset
|
||||||
@ -305,6 +574,46 @@ func (m *QueryParamsResponse) Size() (n int) {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsRequest) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
l = len(m.Denom)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovQuery(uint64(l))
|
||||||
|
}
|
||||||
|
l = len(m.Owner)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovQuery(uint64(l))
|
||||||
|
}
|
||||||
|
if m.Pagination != nil {
|
||||||
|
l = m.Pagination.Size()
|
||||||
|
n += 1 + l + sovQuery(uint64(l))
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *QueryDepositsResponse) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Deposits) > 0 {
|
||||||
|
for _, e := range m.Deposits {
|
||||||
|
l = e.Size()
|
||||||
|
n += 1 + l + sovQuery(uint64(l))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.Pagination != nil {
|
||||||
|
l = m.Pagination.Size()
|
||||||
|
n += 1 + l + sovQuery(uint64(l))
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
func sovQuery(x uint64) (n int) {
|
func sovQuery(x uint64) (n int) {
|
||||||
return (math_bits.Len64(x|1) + 6) / 7
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
}
|
}
|
||||||
@ -444,6 +753,276 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (m *QueryDepositsRequest) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: QueryDepositsRequest: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: QueryDepositsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Denom = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Owner = string(dAtA[iNdEx:postIndex])
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 3:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if m.Pagination == nil {
|
||||||
|
m.Pagination = &query.PageRequest{}
|
||||||
|
}
|
||||||
|
if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (m *QueryDepositsResponse) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: QueryDepositsResponse: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: QueryDepositsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Deposits", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Deposits = append(m.Deposits, Deposit{})
|
||||||
|
if err := m.Deposits[len(m.Deposits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowQuery
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if m.Pagination == nil {
|
||||||
|
m.Pagination = &query.PageResponse{}
|
||||||
|
}
|
||||||
|
if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthQuery
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func skipQuery(dAtA []byte) (n int, err error) {
|
func skipQuery(dAtA []byte) (n int, err error) {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
|
@ -49,6 +49,42 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
filter_Query_Deposits_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
|
)
|
||||||
|
|
||||||
|
func request_Query_Deposits_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryDepositsRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Deposits_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.Deposits(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_Query_Deposits_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq QueryDepositsRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Deposits_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.Deposits(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||||
// UnaryRPC :call QueryServer directly.
|
// UnaryRPC :call QueryServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
@ -75,6 +111,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_Deposits_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_Query_Deposits_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_Deposits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,13 +192,37 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_Query_Deposits_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_Query_Deposits_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_Query_Deposits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "savings", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "savings", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
|
|
||||||
|
pattern_Query_Deposits_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "savings", "v1beta1", "deposits"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
forward_Query_Params_0 = runtime.ForwardResponseMessage
|
forward_Query_Params_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_Query_Deposits_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user