From 7997b263bca6bdf831a8b39231febe4e9aa1c06e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 26 Mar 2022 20:47:01 -0400 Subject: [PATCH] feat: add support for spendable balances gRPC query (backport #11417) (#11459) --- CHANGELOG.md | 1 + proto/cosmos/bank/v1beta1/query.proto | 30 ++ x/bank/keeper/grpc_query.go | 36 ++ x/bank/keeper/grpc_query_test.go | 58 ++- x/bank/keeper/keeper_test.go | 10 +- x/bank/types/querier.go | 7 + x/bank/types/query.pb.go | 635 +++++++++++++++++++++++--- x/bank/types/query.pb.gw.go | 116 +++++ 8 files changed, 821 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d96d62632fe..fcc5f4c88e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (x/bank) [\#11417](https://github.com/cosmos/cosmos-sdk/pull/11417) Introduce a new `SpendableBalances` gRPC query that retrieves an account's total (paginated) spendable balances. * (x/bank) [\#10771](https://github.com/cosmos/cosmos-sdk/pull/10771) Add safety check on bank module perms to allow module-specific mint restrictions (e.g. only minting a certain denom). * (x/bank) [\#10771](https://github.com/cosmos/cosmos-sdk/pull/10771) Add `bank.BankKeeper.WithMintCoinsRestriction` function to restrict use of bank `MintCoins` usage. This function is not on the bank `Keeper` interface, so it's not API-breaking, but only additive on the keeper implementation. * [\#11124](https://github.com/cosmos/cosmos-sdk/pull/11124) Add `GetAllVersions` to application store diff --git a/proto/cosmos/bank/v1beta1/query.proto b/proto/cosmos/bank/v1beta1/query.proto index 520ba0696412..67cebd5fdd53 100644 --- a/proto/cosmos/bank/v1beta1/query.proto +++ b/proto/cosmos/bank/v1beta1/query.proto @@ -21,6 +21,12 @@ service Query { option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}"; } + // SpendableBalances queries the spenable balance of all coins for a single + // account. + rpc SpendableBalances(QuerySpendableBalancesRequest) returns (QuerySpendableBalancesResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/spendable_balances/{address}"; + } + // TotalSupply queries the total supply of all coins. rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/supply"; @@ -88,6 +94,30 @@ message QueryAllBalancesResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// QuerySpendableBalancesRequest defines the gRPC request structure for querying +// an account's spendable balances. +message QuerySpendableBalancesRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address to query spendable balances for. + string address = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QuerySpendableBalancesResponse defines the gRPC response structure for querying +// an account's spendable balances. +message QuerySpendableBalancesResponse { + // balances is the spendable balances of all the coins. + repeated cosmos.base.v1beta1.Coin balances = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. message QueryTotalSupplyRequest { diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 02655aa2f595..e8576d12d629 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -76,6 +76,42 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances return &types.QueryAllBalancesResponse{Balances: balances, Pagination: pageRes}, nil } +// SpendableBalances implements a gRPC query handler for retrieving an account's +// spendable balances. +func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpendableBalancesRequest) (*types.QuerySpendableBalancesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + balances := sdk.NewCoins() + accountStore := k.getAccountStore(sdkCtx, addr) + zeroAmt := sdk.ZeroInt() + + pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { + balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + result := sdk.NewCoins() + spendable := k.SpendableCoins(sdkCtx, addr) + + for _, c := range balances { + result = append(result, sdk.NewCoin(c.Denom, spendable.AmountOf(c.Denom))) + } + + return &types.QuerySpendableBalancesResponse{Balances: result, Pagination: pageRes}, nil +} + // TotalSupply implements the Query/TotalSupply gRPC method func (k BaseKeeper) TotalSupply(ctx context.Context, req *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index 181506a6d7fb..affc6f822d4a 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -3,15 +3,17 @@ package keeper_test import ( gocontext "context" "fmt" + "time" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" - - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) func (suite *IntegrationTestSuite) TestQueryBalance() { @@ -86,6 +88,56 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { suite.Nil(res.Pagination.NextKey) } +func (suite *IntegrationTestSuite) TestSpendableBalances() { + app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient + _, _, addr := testdata.KeyTestPubAddr() + ctx = ctx.WithBlockTime(time.Now()) + + _, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), &types.QuerySpendableBalancesRequest{}) + suite.Require().Error(err) + + pageReq := &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: false, + } + req := types.NewQuerySpendableBalancesRequest(addr, pageReq) + + res, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.True(res.Balances.IsZero()) + + fooCoins := newFooCoin(50) + barCoins := newBarCoin(30) + + origCoins := sdk.NewCoins(fooCoins, barCoins) + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) + acc = vestingtypes.NewContinuousVestingAccount( + acc.(*authtypes.BaseAccount), + sdk.NewCoins(fooCoins), + ctx.BlockTime().Unix(), + ctx.BlockTime().Add(time.Hour).Unix(), + ) + + app.AccountKeeper.SetAccount(ctx, acc) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + + // move time forward for some tokens to vest + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Minute)) + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, app.BankKeeper) + queryClient = types.NewQueryClient(queryHelper) + + res, err = queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Equal(2, res.Balances.Len()) + suite.Nil(res.Pagination.NextKey) + suite.EqualValues(30, res.Balances[0].Amount.Int64()) + suite.EqualValues(25, res.Balances[1].Amount.Int64()) +} + func (suite *IntegrationTestSuite) TestQueryTotalSupply() { app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient expectedTotalSupply := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index ac7877346a9f..e4deabc8acbb 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -5,11 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/types/query" - - "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -18,11 +13,14 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) const ( @@ -97,7 +95,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str func (suite *IntegrationTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) app.BankKeeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/bank/types/querier.go b/x/bank/types/querier.go index 1ef0093386e4..117b87f17c68 100644 --- a/x/bank/types/querier.go +++ b/x/bank/types/querier.go @@ -25,6 +25,13 @@ func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *Qu return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req} } +// NewQuerySpendableBalancesRequest creates a new instance of a +// QuerySpendableBalancesRequest. +// nolint:interfacer +func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest { + return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req} +} + // QueryTotalSupplyParams defines the params for the following queries: // // - 'custom/bank/totalSupply' diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index 0b9ebea6cb6d..e81ca6b3b6fc 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -216,6 +216,104 @@ func (m *QueryAllBalancesResponse) GetPagination() *query.PageResponse { return nil } +// QuerySpendableBalancesRequest defines the gRPC request structure for querying +// an account's spendable balances. +type QuerySpendableBalancesRequest struct { + // address is the address to query spendable balances for. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySpendableBalancesRequest) Reset() { *m = QuerySpendableBalancesRequest{} } +func (m *QuerySpendableBalancesRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableBalancesRequest) ProtoMessage() {} +func (*QuerySpendableBalancesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{4} +} +func (m *QuerySpendableBalancesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableBalancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableBalancesRequest.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 *QuerySpendableBalancesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableBalancesRequest.Merge(m, src) +} +func (m *QuerySpendableBalancesRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableBalancesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableBalancesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableBalancesRequest proto.InternalMessageInfo + +// QuerySpendableBalancesResponse defines the gRPC response structure for querying +// an account's spendable balances. +type QuerySpendableBalancesResponse struct { + // balances is the spendable balances of all the coins. + Balances github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=balances,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balances"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySpendableBalancesResponse) Reset() { *m = QuerySpendableBalancesResponse{} } +func (m *QuerySpendableBalancesResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableBalancesResponse) ProtoMessage() {} +func (*QuerySpendableBalancesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{5} +} +func (m *QuerySpendableBalancesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableBalancesResponse.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 *QuerySpendableBalancesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableBalancesResponse.Merge(m, src) +} +func (m *QuerySpendableBalancesResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableBalancesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableBalancesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableBalancesResponse proto.InternalMessageInfo + +func (m *QuerySpendableBalancesResponse) GetBalances() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Balances + } + return nil +} + +func (m *QuerySpendableBalancesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. type QueryTotalSupplyRequest struct { @@ -229,7 +327,7 @@ func (m *QueryTotalSupplyRequest) Reset() { *m = QueryTotalSupplyRequest func (m *QueryTotalSupplyRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyRequest) ProtoMessage() {} func (*QueryTotalSupplyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{4} + return fileDescriptor_9c6fc1939682df13, []int{6} } func (m *QueryTotalSupplyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -273,7 +371,7 @@ func (m *QueryTotalSupplyResponse) Reset() { *m = QueryTotalSupplyRespon func (m *QueryTotalSupplyResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyResponse) ProtoMessage() {} func (*QueryTotalSupplyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{5} + return fileDescriptor_9c6fc1939682df13, []int{7} } func (m *QueryTotalSupplyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,7 +424,7 @@ func (m *QuerySupplyOfRequest) Reset() { *m = QuerySupplyOfRequest{} } func (m *QuerySupplyOfRequest) String() string { return proto.CompactTextString(m) } func (*QuerySupplyOfRequest) ProtoMessage() {} func (*QuerySupplyOfRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{6} + return fileDescriptor_9c6fc1939682df13, []int{8} } func (m *QuerySupplyOfRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -372,7 +470,7 @@ func (m *QuerySupplyOfResponse) Reset() { *m = QuerySupplyOfResponse{} } func (m *QuerySupplyOfResponse) String() string { return proto.CompactTextString(m) } func (*QuerySupplyOfResponse) ProtoMessage() {} func (*QuerySupplyOfResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{7} + return fileDescriptor_9c6fc1939682df13, []int{9} } func (m *QuerySupplyOfResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -416,7 +514,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{8} + return fileDescriptor_9c6fc1939682df13, []int{10} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +552,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{9} + return fileDescriptor_9c6fc1939682df13, []int{11} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -500,7 +598,7 @@ func (m *QueryDenomsMetadataRequest) Reset() { *m = QueryDenomsMetadataR func (m *QueryDenomsMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomsMetadataRequest) ProtoMessage() {} func (*QueryDenomsMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{10} + return fileDescriptor_9c6fc1939682df13, []int{12} } func (m *QueryDenomsMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -549,7 +647,7 @@ func (m *QueryDenomsMetadataResponse) Reset() { *m = QueryDenomsMetadata func (m *QueryDenomsMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomsMetadataResponse) ProtoMessage() {} func (*QueryDenomsMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{11} + return fileDescriptor_9c6fc1939682df13, []int{13} } func (m *QueryDenomsMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -602,7 +700,7 @@ func (m *QueryDenomMetadataRequest) Reset() { *m = QueryDenomMetadataReq func (m *QueryDenomMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomMetadataRequest) ProtoMessage() {} func (*QueryDenomMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{12} + return fileDescriptor_9c6fc1939682df13, []int{14} } func (m *QueryDenomMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -649,7 +747,7 @@ func (m *QueryDenomMetadataResponse) Reset() { *m = QueryDenomMetadataRe func (m *QueryDenomMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomMetadataResponse) ProtoMessage() {} func (*QueryDenomMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{13} + return fileDescriptor_9c6fc1939682df13, []int{15} } func (m *QueryDenomMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -690,6 +788,8 @@ func init() { proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v1beta1.QueryBalanceResponse") proto.RegisterType((*QueryAllBalancesRequest)(nil), "cosmos.bank.v1beta1.QueryAllBalancesRequest") proto.RegisterType((*QueryAllBalancesResponse)(nil), "cosmos.bank.v1beta1.QueryAllBalancesResponse") + proto.RegisterType((*QuerySpendableBalancesRequest)(nil), "cosmos.bank.v1beta1.QuerySpendableBalancesRequest") + proto.RegisterType((*QuerySpendableBalancesResponse)(nil), "cosmos.bank.v1beta1.QuerySpendableBalancesResponse") proto.RegisterType((*QueryTotalSupplyRequest)(nil), "cosmos.bank.v1beta1.QueryTotalSupplyRequest") proto.RegisterType((*QueryTotalSupplyResponse)(nil), "cosmos.bank.v1beta1.QueryTotalSupplyResponse") proto.RegisterType((*QuerySupplyOfRequest)(nil), "cosmos.bank.v1beta1.QuerySupplyOfRequest") @@ -705,59 +805,63 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ - // 829 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6b, 0x13, 0x5b, - 0x18, 0xce, 0xe9, 0xbd, 0x4d, 0xd3, 0x37, 0xdc, 0xbb, 0x38, 0xcd, 0xe5, 0xa6, 0xd3, 0xdb, 0xe4, - 0x32, 0xd5, 0x36, 0xad, 0xe9, 0x4c, 0x9b, 0x0a, 0x7e, 0x6c, 0xa4, 0xa9, 0xe8, 0x42, 0xa4, 0x31, - 0xba, 0x12, 0xa4, 0x9c, 0x24, 0xe3, 0x18, 0x9a, 0xcc, 0x99, 0xe6, 0x4c, 0xc4, 0x50, 0x0a, 0x22, - 0x08, 0xae, 0x54, 0x70, 0x23, 0xb8, 0xa9, 0x1b, 0x41, 0xb7, 0xfe, 0x89, 0x2e, 0x5c, 0x14, 0xdc, - 0xb8, 0x52, 0x69, 0x5d, 0xf8, 0x33, 0x24, 0xe7, 0x23, 0x9d, 0x24, 0xd3, 0x64, 0x16, 0x71, 0x95, - 0x99, 0x77, 0xde, 0x8f, 0xe7, 0x79, 0xce, 0xbc, 0xcf, 0x04, 0xd2, 0x65, 0xca, 0xea, 0x94, 0x99, - 0x25, 0xe2, 0x6c, 0x9b, 0x0f, 0x57, 0x4b, 0x96, 0x47, 0x56, 0xcd, 0x9d, 0xa6, 0xd5, 0x68, 0x19, - 0x6e, 0x83, 0x7a, 0x14, 0x4f, 0x89, 0x04, 0xa3, 0x9d, 0x60, 0xc8, 0x04, 0x6d, 0xa9, 0x53, 0xc5, - 0x2c, 0x91, 0xdd, 0xa9, 0x75, 0x89, 0x5d, 0x75, 0x88, 0x57, 0xa5, 0x8e, 0x68, 0xa0, 0x25, 0x6c, - 0x6a, 0x53, 0x7e, 0x69, 0xb6, 0xaf, 0x64, 0xf4, 0x3f, 0x9b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, 0xa0, 0x59, 0x32, 0xca, 0xb4, 0x6e, 0xca, 0x23, 0x12, 0x3f, 0xcb, 0xac, 0xb2, 0x6d, 0x7a, - 0x2d, 0xd7, 0x62, 0xbc, 0x80, 0x15, 0x3b, 0xcd, 0xf1, 0xf5, 0x00, 0x5e, 0x0b, 0x43, 0x79, 0x09, - 0x94, 0x7e, 0x62, 0xfa, 0xb6, 0x54, 0xf5, 0x0e, 0xf5, 0x48, 0xed, 0x76, 0xd3, 0x75, 0x6b, 0x2d, - 0xa5, 0x6a, 0xb7, 0x76, 0x68, 0x04, 0xda, 0x1d, 0x28, 0xed, 0xba, 0xa6, 0x49, 0xed, 0xca, 0x10, - 0x65, 0x3c, 0xf2, 0x3b, 0x94, 0x93, 0xad, 0x47, 0xa7, 0x5b, 0x56, 0xbe, 0xdb, 0x82, 0xc4, 0xe6, - 0x7d, 0x25, 0x5a, 0x67, 0x27, 0x90, 0x6f, 0x27, 0xf4, 0x02, 0xfc, 0xd3, 0x93, 0x2d, 0x49, 0x5f, - 0x80, 0x28, 0xa9, 0xd3, 0xa6, 0xe3, 0x0d, 0xdd, 0x84, 0xfc, 0x9f, 0x6d, 0xd2, 0x45, 0x99, 0xae, - 0x27, 0x00, 0xf3, 0x8e, 0x05, 0xd2, 0x20, 0x75, 0xb5, 0x08, 0x7a, 0x41, 0xae, 0xb0, 0x8a, 0xca, - 0x29, 0x97, 0x20, 0xea, 0xf2, 0x88, 0x9c, 0x32, 0x63, 0x04, 0xf8, 0x93, 0x21, 0x8a, 0xd4, 0x1c, - 0x51, 0xa0, 0x57, 0x40, 0xe3, 0x1d, 0xaf, 0xb6, 0x79, 0xb0, 0x9b, 0x96, 0x47, 0x2a, 0xc4, 0x23, - 0x23, 0x7e, 0x45, 0xf4, 0xf7, 0x08, 0x66, 0x02, 0xc7, 0x48, 0x02, 0xeb, 0x30, 0x59, 0x97, 0x31, - 0xb5, 0x58, 0xb3, 0x81, 0x1c, 0x54, 0xa5, 0x64, 0x71, 0x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xf0, 0x57, 0xd7, 0x0e, 0x61, 0xe3, 0xf4, 0x01, 0x41, 0xfb, 0xa9, 0x99, 0xa1, 0xf3, 0x25, 0xae, - 0xf3, 0x1c, 0x97, 0x81, 0xb3, 0x81, 0xb8, 0xb8, 0x34, 0x6c, 0x4b, 0x6d, 0x62, 0x47, 0xab, 0xb7, - 0x08, 0xfe, 0xee, 0xb6, 0x32, 0x3c, 0x6c, 0x72, 0xaf, 0xb7, 0x6a, 0x2b, 0xe1, 0x0b, 0x24, 0xd6, - 0x2c, 0xc7, 0x3a, 0x8f, 0xcf, 0x84, 0xc1, 0x9a, 0xdf, 0x38, 0x38, 0x4a, 0xa1, 0xc3, 0xa3, 0x14, - 0xfa, 0x7e, 0x94, 0x42, 0x2f, 0x8f, 0x53, 0x91, 0xc3, 0xe3, 0x54, 0xe4, 0xcb, 0x71, 0x2a, 0x72, - 0x77, 0x71, 0xe0, 0x67, 0xf5, 0x91, 0x68, 0xcb, 0xbf, 0xae, 0xa5, 0x28, 0xff, 0xeb, 0xb8, 0xf6, - 0x2b, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x6f, 0x29, 0xd7, 0x12, 0x0b, 0x00, 0x00, + // 896 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x97, 0x5d, 0x6b, 0x23, 0x55, + 0x18, 0xc7, 0x73, 0xaa, 0x4d, 0xd3, 0x27, 0x28, 0x78, 0x1a, 0x31, 0x9d, 0xda, 0x89, 0x4c, 0xb5, + 0x4d, 0x6b, 0x3a, 0xd3, 0x24, 0x82, 0xd6, 0x1b, 0x69, 0x2a, 0x7a, 0x21, 0xd2, 0x98, 0x7a, 0x25, + 0x48, 0x39, 0x49, 0xc6, 0x31, 0x34, 0x99, 0x33, 0xcd, 0x99, 0x88, 0xa1, 0x14, 0x44, 0x10, 0x04, + 0x41, 0x05, 0x6f, 0x04, 0x6f, 0xea, 0x8d,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0x8a, 0x1c, + 0x2f, 0xb9, 0xde, 0xe3, 0x5c, 0x26, 0xce, 0x85, 0x72, 0x71, 0x69, 0xd8, 0x91, 0xf2, 0x90, 0xbe, + 0x56, 0x7f, 0x23, 0x78, 0x75, 0xd0, 0x84, 0xf1, 0xb4, 0xce, 0xc3, 0xb7, 0x82, 0xb6, 0x13, 0x3d, + 0x41, 0xb2, 0xe6, 0x38, 0xeb, 0x3a, 0x7e, 0x3b, 0x0a, 0x6b, 0x69, 0xff, 0xe2, 0x4a, 0x47, 0x97, + 0x57, 0x3a, 0x7a, 0x70, 0xa5, 0xa3, 0xdf, 0xaf, 0xf5, 0xd8, 0xe5, 0xb5, 0x1e, 0xbb, 0x7b, 0xad, + 0xc7, 0xbe, 0xda, 0x9c, 0xf8, 0x83, 0xe0, 0x7b, 0x51, 0x96, 0xff, 0x2e, 0xa8, 0xc6, 0xf9, 0xff, + 0x15, 0xc5, 0x27, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd1, 0xfd, 0x88, 0xa1, 0x2f, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -776,6 +880,9 @@ type QueryClient interface { Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(ctx context.Context, in *QueryAllBalancesRequest, opts ...grpc.CallOption) (*QueryAllBalancesResponse, error) + // SpendableBalances queries the spenable balance of all coins for a single + // account. + SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) // SupplyOf queries the supply of a single coin. @@ -814,6 +921,15 @@ func (c *queryClient) AllBalances(ctx context.Context, in *QueryAllBalancesReque return out, nil } +func (c *queryClient) SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error) { + out := new(QuerySpendableBalancesResponse) + err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/SpendableBalances", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) { out := new(QueryTotalSupplyResponse) err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/TotalSupply", in, out, opts...) @@ -865,6 +981,9 @@ type QueryServer interface { Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(context.Context, *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) + // SpendableBalances queries the spenable balance of all coins for a single + // account. + SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) // SupplyOf queries the supply of a single coin. @@ -887,6 +1006,9 @@ func (*UnimplementedQueryServer) Balance(ctx context.Context, req *QueryBalanceR func (*UnimplementedQueryServer) AllBalances(ctx context.Context, req *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllBalances not implemented") } +func (*UnimplementedQueryServer) SpendableBalances(ctx context.Context, req *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpendableBalances not implemented") +} func (*UnimplementedQueryServer) TotalSupply(ctx context.Context, req *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalSupply not implemented") } @@ -943,6 +1065,24 @@ func _Query_AllBalances_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_SpendableBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySpendableBalancesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SpendableBalances(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.bank.v1beta1.Query/SpendableBalances", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SpendableBalances(ctx, req.(*QuerySpendableBalancesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_TotalSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryTotalSupplyRequest) if err := dec(in); err != nil { @@ -1045,6 +1185,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "AllBalances", Handler: _Query_AllBalances_Handler, }, + { + MethodName: "SpendableBalances", + Handler: _Query_SpendableBalances_Handler, + }, { MethodName: "TotalSupply", Handler: _Query_TotalSupply_Handler, @@ -1233,6 +1377,97 @@ func (m *QueryAllBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QuerySpendableBalancesRequest) 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 *QuerySpendableBalancesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableBalancesRequest) 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.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySpendableBalancesResponse) 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 *QuerySpendableBalancesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableBalancesResponse) 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.Balances) > 0 { + for iNdEx := len(m.Balances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balances[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 (m *QueryTotalSupplyRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1660,6 +1895,42 @@ func (m *QueryAllBalancesResponse) Size() (n int) { return n } +func (m *QuerySpendableBalancesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + 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 *QuerySpendableBalancesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Balances) > 0 { + for _, e := range m.Balances { + 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 (m *QueryTotalSupplyRequest) Size() (n int) { if m == nil { return 0 @@ -2236,6 +2507,244 @@ func (m *QueryAllBalancesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QuerySpendableBalancesRequest) 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: QuerySpendableBalancesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableBalancesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = string(dAtA[iNdEx:postIndex]) + 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.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 *QuerySpendableBalancesResponse) 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: QuerySpendableBalancesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableBalancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balances", 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.Balances = append(m.Balances, types.Coin{}) + if err := m.Balances[len(m.Balances)-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 (m *QueryTotalSupplyRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/bank/types/query.pb.gw.go b/x/bank/types/query.pb.gw.go index 4cd12b258912..a6ea74de978b 100644 --- a/x/bank/types/query.pb.gw.go +++ b/x/bank/types/query.pb.gw.go @@ -175,6 +175,78 @@ func local_request_Query_AllBalances_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_Query_SpendableBalances_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_SpendableBalances_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpendableBalancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpendableBalances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SpendableBalances(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SpendableBalances_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpendableBalancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpendableBalances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SpendableBalances(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_TotalSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -419,6 +491,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_SpendableBalances_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_SpendableBalances_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_SpendableBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -600,6 +692,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_SpendableBalances_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_SpendableBalances_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_SpendableBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -708,6 +820,8 @@ var ( pattern_Query_AllBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "balances", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_SpendableBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "spendable_balances", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TotalSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "supply"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_SupplyOf_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "supply", "denom"}, "", runtime.AssumeColonVerbOpt(false))) @@ -724,6 +838,8 @@ var ( forward_Query_AllBalances_0 = runtime.ForwardResponseMessage + forward_Query_SpendableBalances_0 = runtime.ForwardResponseMessage + forward_Query_TotalSupply_0 = runtime.ForwardResponseMessage forward_Query_SupplyOf_0 = runtime.ForwardResponseMessage