diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 59ab3188..da9147e5 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -481,6 +481,10 @@ - [GenesisState](#kava.precisebank.v1.GenesisState) - [kava/precisebank/v1/query.proto](#kava/precisebank/v1/query.proto) + - [QueryFractionalBalanceRequest](#kava.precisebank.v1.QueryFractionalBalanceRequest) + - [QueryFractionalBalanceResponse](#kava.precisebank.v1.QueryFractionalBalanceResponse) + - [QueryRemainderRequest](#kava.precisebank.v1.QueryRemainderRequest) + - [QueryRemainderResponse](#kava.precisebank.v1.QueryRemainderResponse) - [QueryTotalFractionalBalancesRequest](#kava.precisebank.v1.QueryTotalFractionalBalancesRequest) - [QueryTotalFractionalBalancesResponse](#kava.precisebank.v1.QueryTotalFractionalBalancesResponse) @@ -6689,6 +6693,61 @@ GenesisState defines the precisebank module's genesis state. + + +### QueryFractionalBalanceRequest +QueryFractionalBalanceRequest defines the request type for Query/FractionalBalance method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | address is the account address to query fractional balance for. | + + + + + + + + +### QueryFractionalBalanceResponse +QueryFractionalBalanceResponse defines the response type for Query/FractionalBalance method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fractional_balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | fractional_balance is the fractional balance of the address. | + + + + + + + + +### QueryRemainderRequest +QueryRemainderRequest defines the request type for Query/Remainder method. + + + + + + + + +### QueryRemainderResponse +QueryRemainderResponse defines the response type for Query/Remainder method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `remainder` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | remainder is the amount backed by the reserve, but not yet owned by any account, i.e. not in circulation. | + + + + + + ### QueryTotalFractionalBalancesRequest @@ -6728,6 +6787,8 @@ Query defines the gRPC querier service for precisebank module | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `TotalFractionalBalances` | [QueryTotalFractionalBalancesRequest](#kava.precisebank.v1.QueryTotalFractionalBalancesRequest) | [QueryTotalFractionalBalancesResponse](#kava.precisebank.v1.QueryTotalFractionalBalancesResponse) | TotalFractionalBalances returns the total sum of all fractional balances managed by the precisebank module. | GET|/kava/precisebank/v1/total_fractional_balances| +| `Remainder` | [QueryRemainderRequest](#kava.precisebank.v1.QueryRemainderRequest) | [QueryRemainderResponse](#kava.precisebank.v1.QueryRemainderResponse) | Remainder returns the amount backed by the reserve, but not yet owned by any account, i.e. not in circulation. | GET|/kava/precisebank/v1/remainder| +| `FractionalBalance` | [QueryFractionalBalanceRequest](#kava.precisebank.v1.QueryFractionalBalanceRequest) | [QueryFractionalBalanceResponse](#kava.precisebank.v1.QueryFractionalBalanceResponse) | FractionalBalance returns only the fractional balance of an address. This does not include any integer balance. | GET|/kava/precisebank/v1/fractional_balance/{address}| diff --git a/proto/kava/precisebank/v1/query.proto b/proto/kava/precisebank/v1/query.proto index 45ef7b90..45abd90c 100644 --- a/proto/kava/precisebank/v1/query.proto +++ b/proto/kava/precisebank/v1/query.proto @@ -15,6 +15,18 @@ service Query { rpc TotalFractionalBalances(QueryTotalFractionalBalancesRequest) returns (QueryTotalFractionalBalancesResponse) { option (google.api.http).get = "/kava/precisebank/v1/total_fractional_balances"; } + + // Remainder returns the amount backed by the reserve, but not yet owned by + // any account, i.e. not in circulation. + rpc Remainder(QueryRemainderRequest) returns (QueryRemainderResponse) { + option (google.api.http).get = "/kava/precisebank/v1/remainder"; + } + + // FractionalBalance returns only the fractional balance of an address. This + // does not include any integer balance. + rpc FractionalBalance(QueryFractionalBalanceRequest) returns (QueryFractionalBalanceResponse) { + option (google.api.http).get = "/kava/precisebank/v1/fractional_balance/{address}"; + } } // QueryTotalFractionalBalancesRequest defines the request type for Query/TotalFractionalBalances method. @@ -26,3 +38,25 @@ message QueryTotalFractionalBalancesResponse { // module. cosmos.base.v1beta1.Coin total = 1 [(gogoproto.nullable) = false]; } + +// QueryRemainderRequest defines the request type for Query/Remainder method. +message QueryRemainderRequest {} + +// QueryRemainderResponse defines the response type for Query/Remainder method. +message QueryRemainderResponse { + // remainder is the amount backed by the reserve, but not yet owned by any + // account, i.e. not in circulation. + cosmos.base.v1beta1.Coin remainder = 1 [(gogoproto.nullable) = false]; +} + +// QueryFractionalBalanceRequest defines the request type for Query/FractionalBalance method. +message QueryFractionalBalanceRequest { + // address is the account address to query fractional balance for. + string address = 1; +} + +// QueryFractionalBalanceResponse defines the response type for Query/FractionalBalance method. +message QueryFractionalBalanceResponse { + // fractional_balance is the fractional balance of the address. + cosmos.base.v1beta1.Coin fractional_balance = 1 [(gogoproto.nullable) = false]; +} diff --git a/x/precisebank/keeper/grpc_query.go b/x/precisebank/keeper/grpc_query.go index d3803ed5..44dc8f7f 100644 --- a/x/precisebank/keeper/grpc_query.go +++ b/x/precisebank/keeper/grpc_query.go @@ -36,3 +36,38 @@ func (s queryServer) TotalFractionalBalances( Total: totalCoin, }, nil } + +// Remainder returns the remainder amount in x/precisebank. +func (s queryServer) Remainder( + goCtx context.Context, + req *types.QueryRemainderRequest, +) (*types.QueryRemainderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + remainder := s.keeper.GetRemainderAmount(ctx) + remainderCoin := sdk.NewCoin(types.ExtendedCoinDenom, remainder) + + return &types.QueryRemainderResponse{ + Remainder: remainderCoin, + }, nil +} + +// FractionalBalance returns the fractional balance of an account. +func (s queryServer) FractionalBalance( + goCtx context.Context, + req *types.QueryFractionalBalanceRequest, +) (*types.QueryFractionalBalanceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + address, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + + amt := s.keeper.GetFractionalBalance(ctx, address) + fractionalBalance := sdk.NewCoin(types.ExtendedCoinDenom, amt) + + return &types.QueryFractionalBalanceResponse{ + FractionalBalance: fractionalBalance, + }, nil +} diff --git a/x/precisebank/keeper/grpc_query_test.go b/x/precisebank/keeper/grpc_query_test.go index c4245f99..ad0073d2 100644 --- a/x/precisebank/keeper/grpc_query_test.go +++ b/x/precisebank/keeper/grpc_query_test.go @@ -8,6 +8,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/stretchr/testify/suite" "github.com/kava-labs/kava/x/precisebank/keeper" @@ -84,3 +85,87 @@ func (suite *grpcQueryTestSuite) TestQueryTotalFractionalBalance() { }) } } + +func (suite *grpcQueryTestSuite) TestQueryRemainder() { + res, err := suite.queryClient.Remainder( + context.Background(), + &types.QueryRemainderRequest{}, + ) + suite.Require().NoError(err) + + expRemainder := sdk.NewCoin(types.ExtendedCoinDenom, sdkmath.ZeroInt()) + suite.Require().Equal(expRemainder, res.Remainder) + + // Mint fractional coins to create non-zero remainder + + pbk := suite.App.GetPrecisebankKeeper() + + coin := sdk.NewCoin(types.ExtendedCoinDenom, sdkmath.OneInt()) + err = pbk.MintCoins( + suite.Ctx, + minttypes.ModuleName, + sdk.NewCoins(coin), + ) + suite.Require().NoError(err) + + res, err = suite.queryClient.Remainder( + context.Background(), + &types.QueryRemainderRequest{}, + ) + suite.Require().NoError(err) + + expRemainder.Amount = types.ConversionFactor().Sub(coin.Amount) + suite.Require().Equal(expRemainder, res.Remainder) +} + +func (suite *grpcQueryTestSuite) TestQueryFractionalBalance() { + testCases := []struct { + name string + giveBalance sdkmath.Int + }{ + { + "zero", + sdkmath.ZeroInt(), + }, + { + "min amount", + sdkmath.OneInt(), + }, + { + "max amount", + types.ConversionFactor().SubRaw(1), + }, + { + "multiple integer amounts, 0 fractional", + types.ConversionFactor().MulRaw(5), + }, + { + "multiple integer amounts, non-zero fractional", + types.ConversionFactor().MulRaw(5).Add(types.ConversionFactor().QuoRaw(2)), + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() + + addr := sdk.AccAddress([]byte("test")) + + coin := sdk.NewCoin(types.ExtendedCoinDenom, tc.giveBalance) + suite.MintToAccount(addr, sdk.NewCoins(coin)) + + res, err := suite.queryClient.FractionalBalance( + context.Background(), + &types.QueryFractionalBalanceRequest{ + Address: addr.String(), + }, + ) + suite.Require().NoError(err) + + // Only fractional amount, even if minted more than conversion factor + expAmount := tc.giveBalance.Mod(types.ConversionFactor()) + expFractionalBalance := sdk.NewCoin(types.ExtendedCoinDenom, expAmount) + suite.Require().Equal(expFractionalBalance, res.FractionalBalance) + }) + } +} diff --git a/x/precisebank/types/query.pb.go b/x/precisebank/types/query.pb.go index 91d41aa4..b324a225 100644 --- a/x/precisebank/types/query.pb.go +++ b/x/precisebank/types/query.pb.go @@ -107,36 +107,205 @@ func (m *QueryTotalFractionalBalancesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTotalFractionalBalancesResponse proto.InternalMessageInfo +// QueryRemainderRequest defines the request type for Query/Remainder method. +type QueryRemainderRequest struct { +} + +func (m *QueryRemainderRequest) Reset() { *m = QueryRemainderRequest{} } +func (m *QueryRemainderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRemainderRequest) ProtoMessage() {} +func (*QueryRemainderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8a91a8caa7551030, []int{2} +} +func (m *QueryRemainderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRemainderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRemainderRequest.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 *QueryRemainderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRemainderRequest.Merge(m, src) +} +func (m *QueryRemainderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRemainderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRemainderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRemainderRequest proto.InternalMessageInfo + +// QueryRemainderResponse defines the response type for Query/Remainder method. +type QueryRemainderResponse struct { + // remainder is the amount backed by the reserve, but not yet owned by any + // account, i.e. not in circulation. + Remainder types.Coin `protobuf:"bytes,1,opt,name=remainder,proto3" json:"remainder"` +} + +func (m *QueryRemainderResponse) Reset() { *m = QueryRemainderResponse{} } +func (m *QueryRemainderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRemainderResponse) ProtoMessage() {} +func (*QueryRemainderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8a91a8caa7551030, []int{3} +} +func (m *QueryRemainderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRemainderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRemainderResponse.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 *QueryRemainderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRemainderResponse.Merge(m, src) +} +func (m *QueryRemainderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRemainderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRemainderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRemainderResponse proto.InternalMessageInfo + +// QueryFractionalBalanceRequest defines the request type for Query/FractionalBalance method. +type QueryFractionalBalanceRequest struct { + // address is the account address to query fractional balance for. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryFractionalBalanceRequest) Reset() { *m = QueryFractionalBalanceRequest{} } +func (m *QueryFractionalBalanceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFractionalBalanceRequest) ProtoMessage() {} +func (*QueryFractionalBalanceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8a91a8caa7551030, []int{4} +} +func (m *QueryFractionalBalanceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFractionalBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFractionalBalanceRequest.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 *QueryFractionalBalanceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFractionalBalanceRequest.Merge(m, src) +} +func (m *QueryFractionalBalanceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFractionalBalanceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFractionalBalanceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFractionalBalanceRequest proto.InternalMessageInfo + +// QueryFractionalBalanceResponse defines the response type for Query/FractionalBalance method. +type QueryFractionalBalanceResponse struct { + // fractional_balance is the fractional balance of the address. + FractionalBalance types.Coin `protobuf:"bytes,1,opt,name=fractional_balance,json=fractionalBalance,proto3" json:"fractional_balance"` +} + +func (m *QueryFractionalBalanceResponse) Reset() { *m = QueryFractionalBalanceResponse{} } +func (m *QueryFractionalBalanceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFractionalBalanceResponse) ProtoMessage() {} +func (*QueryFractionalBalanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8a91a8caa7551030, []int{5} +} +func (m *QueryFractionalBalanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFractionalBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFractionalBalanceResponse.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 *QueryFractionalBalanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFractionalBalanceResponse.Merge(m, src) +} +func (m *QueryFractionalBalanceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFractionalBalanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFractionalBalanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFractionalBalanceResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryTotalFractionalBalancesRequest)(nil), "kava.precisebank.v1.QueryTotalFractionalBalancesRequest") proto.RegisterType((*QueryTotalFractionalBalancesResponse)(nil), "kava.precisebank.v1.QueryTotalFractionalBalancesResponse") + proto.RegisterType((*QueryRemainderRequest)(nil), "kava.precisebank.v1.QueryRemainderRequest") + proto.RegisterType((*QueryRemainderResponse)(nil), "kava.precisebank.v1.QueryRemainderResponse") + proto.RegisterType((*QueryFractionalBalanceRequest)(nil), "kava.precisebank.v1.QueryFractionalBalanceRequest") + proto.RegisterType((*QueryFractionalBalanceResponse)(nil), "kava.precisebank.v1.QueryFractionalBalanceResponse") } func init() { proto.RegisterFile("kava/precisebank/v1/query.proto", fileDescriptor_8a91a8caa7551030) } var fileDescriptor_8a91a8caa7551030 = []byte{ - // 334 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xc1, 0x4a, 0x3b, 0x31, - 0x10, 0xc6, 0x37, 0x7f, 0xfe, 0xf5, 0xb0, 0xde, 0x56, 0x41, 0x2d, 0x92, 0x4a, 0x55, 0xf0, 0xd2, - 0xc4, 0xad, 0x28, 0x7a, 0xad, 0xe0, 0xc5, 0x93, 0xc5, 0x93, 0x20, 0x65, 0xb2, 0xc4, 0x75, 0xe9, - 0x36, 0xb3, 0xdd, 0xa4, 0x8b, 0xbd, 0xfa, 0x04, 0x82, 0xef, 0x24, 0x3d, 0x16, 0xbc, 0x78, 0x12, - 0x6d, 0x7d, 0x10, 0xc9, 0xa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0xed, 0xfe, 0xdf, 0x6e, - 0xc0, 0xf8, 0xbc, 0x9b, 0x95, 0xf8, 0x9d, 0xab, 0x0f, 0x7b, 0x47, 0xcc, 0xfc, 0xad, 0xd3, 0xd1, - 0x2b, 0xf5, 0x46, 0x13, 0x4a, 0xc6, 0x13, 0x4a, 0x5e, 0x26, 0x94, 0xdc, 0x4d, 0xa9, 0x37, 0x9e, - 0x52, 0xef, 0x69, 0x4a, 0xbd, 0x8b, 0x46, 0x9c, 0x98, 0xeb, 0x81, 0x60, 0x11, 0xf6, 0xca, 0xb9, - 0x8d, 0x14, 0x84, 0x76, 0x09, 0x37, 0x5f, 0x32, 0xcc, 0x30, 0x93, 0x5a, 0x2c, 0x94, 0xc7, 0xda, - 0x7b, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x42, 0xb7, 0x92, 0x38, 0x02, 0x00, 0x00, + // 486 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4d, 0x8b, 0xd3, 0x40, + 0x18, 0xc7, 0x33, 0xb2, 0xab, 0x74, 0x3c, 0xed, 0xf8, 0xb2, 0x6b, 0xd0, 0xd9, 0x25, 0xbe, 0x20, + 0xca, 0xce, 0x98, 0x16, 0xc5, 0x1e, 0xbc, 0x54, 0xf0, 0x22, 0x08, 0x16, 0x41, 0x10, 0x64, 0x79, + 0x92, 0xce, 0xc6, 0xb0, 0xe9, 0x4c, 0x36, 0x33, 0x2d, 0x2e, 0xe2, 0xc5, 0xb3, 0x07, 0xc1, 0x93, + 0x9f, 0xc4, 0x6f, 0x20, 0x3d, 0x2e, 0x78, 0xf1, 0x24, 0xda, 0xfa, 0x41, 0x24, 0x93, 0x69, 0xd5, + 0xb6, 0x91, 0xea, 0x6d, 0x32, 0xcf, 0xcb, 0xff, 0xf7, 0xcc, 0xf3, 0x27, 0x78, 0xfb, 0x00, 0x86, + 0xc0, 0xf3, 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, 0x43, 0xc6, + 0x1c, 0xe5, 0x42, 0x47, 0x27, 0xed, 0x4f, 0xa1, 0xf5, 0x33, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x25, + 0x13, 0x91, 0xa0, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -154,6 +323,12 @@ type QueryClient interface { // TotalFractionalBalances returns the total sum of all fractional balances // managed by the precisebank module. TotalFractionalBalances(ctx context.Context, in *QueryTotalFractionalBalancesRequest, opts ...grpc.CallOption) (*QueryTotalFractionalBalancesResponse, error) + // Remainder returns the amount backed by the reserve, but not yet owned by + // any account, i.e. not in circulation. + Remainder(ctx context.Context, in *QueryRemainderRequest, opts ...grpc.CallOption) (*QueryRemainderResponse, error) + // FractionalBalance returns only the fractional balance of an address. This + // does not include any integer balance. + FractionalBalance(ctx context.Context, in *QueryFractionalBalanceRequest, opts ...grpc.CallOption) (*QueryFractionalBalanceResponse, error) } type queryClient struct { @@ -173,11 +348,35 @@ func (c *queryClient) TotalFractionalBalances(ctx context.Context, in *QueryTota return out, nil } +func (c *queryClient) Remainder(ctx context.Context, in *QueryRemainderRequest, opts ...grpc.CallOption) (*QueryRemainderResponse, error) { + out := new(QueryRemainderResponse) + err := c.cc.Invoke(ctx, "/kava.precisebank.v1.Query/Remainder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) FractionalBalance(ctx context.Context, in *QueryFractionalBalanceRequest, opts ...grpc.CallOption) (*QueryFractionalBalanceResponse, error) { + out := new(QueryFractionalBalanceResponse) + err := c.cc.Invoke(ctx, "/kava.precisebank.v1.Query/FractionalBalance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // TotalFractionalBalances returns the total sum of all fractional balances // managed by the precisebank module. TotalFractionalBalances(context.Context, *QueryTotalFractionalBalancesRequest) (*QueryTotalFractionalBalancesResponse, error) + // Remainder returns the amount backed by the reserve, but not yet owned by + // any account, i.e. not in circulation. + Remainder(context.Context, *QueryRemainderRequest) (*QueryRemainderResponse, error) + // FractionalBalance returns only the fractional balance of an address. This + // does not include any integer balance. + FractionalBalance(context.Context, *QueryFractionalBalanceRequest) (*QueryFractionalBalanceResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -187,6 +386,12 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) TotalFractionalBalances(ctx context.Context, req *QueryTotalFractionalBalancesRequest) (*QueryTotalFractionalBalancesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalFractionalBalances not implemented") } +func (*UnimplementedQueryServer) Remainder(ctx context.Context, req *QueryRemainderRequest) (*QueryRemainderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Remainder not implemented") +} +func (*UnimplementedQueryServer) FractionalBalance(ctx context.Context, req *QueryFractionalBalanceRequest) (*QueryFractionalBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FractionalBalance not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -210,6 +415,42 @@ func _Query_TotalFractionalBalances_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _Query_Remainder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRemainderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Remainder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kava.precisebank.v1.Query/Remainder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Remainder(ctx, req.(*QueryRemainderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_FractionalBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFractionalBalanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).FractionalBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kava.precisebank.v1.Query/FractionalBalance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FractionalBalance(ctx, req.(*QueryFractionalBalanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "kava.precisebank.v1.Query", HandlerType: (*QueryServer)(nil), @@ -218,6 +459,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TotalFractionalBalances", Handler: _Query_TotalFractionalBalances_Handler, }, + { + MethodName: "Remainder", + Handler: _Query_Remainder_Handler, + }, + { + MethodName: "FractionalBalance", + Handler: _Query_FractionalBalance_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "kava/precisebank/v1/query.proto", @@ -279,6 +528,125 @@ func (m *QueryTotalFractionalBalancesResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *QueryRemainderRequest) 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 *QueryRemainderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRemainderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryRemainderResponse) 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 *QueryRemainderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRemainderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Remainder.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 *QueryFractionalBalanceRequest) 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 *QueryFractionalBalanceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFractionalBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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 *QueryFractionalBalanceResponse) 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 *QueryFractionalBalanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFractionalBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.FractionalBalance.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 { offset -= sovQuery(v) base := offset @@ -310,6 +678,50 @@ func (m *QueryTotalFractionalBalancesResponse) Size() (n int) { return n } +func (m *QueryRemainderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryRemainderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Remainder.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryFractionalBalanceRequest) 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)) + } + return n +} + +func (m *QueryFractionalBalanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.FractionalBalance.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -449,6 +861,304 @@ func (m *QueryTotalFractionalBalancesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryRemainderRequest) 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: QueryRemainderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRemainderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryRemainderResponse) 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: QueryRemainderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRemainderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Remainder", 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 err := m.Remainder.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 *QueryFractionalBalanceRequest) 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: QueryFractionalBalanceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFractionalBalanceRequest: 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 + 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 *QueryFractionalBalanceResponse) 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: QueryFractionalBalanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFractionalBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FractionalBalance", 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 err := m.FractionalBalance.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) { l := len(dAtA) iNdEx := 0 diff --git a/x/precisebank/types/query.pb.gw.go b/x/precisebank/types/query.pb.gw.go index 777963c3..b34d7205 100644 --- a/x/precisebank/types/query.pb.gw.go +++ b/x/precisebank/types/query.pb.gw.go @@ -51,6 +51,78 @@ func local_request_Query_TotalFractionalBalances_0(ctx context.Context, marshale } +func request_Query_Remainder_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRemainderRequest + var metadata runtime.ServerMetadata + + msg, err := client.Remainder(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Remainder_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRemainderRequest + var metadata runtime.ServerMetadata + + msg, err := server.Remainder(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_FractionalBalance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFractionalBalanceRequest + 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) + } + + msg, err := client.FractionalBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FractionalBalance_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFractionalBalanceRequest + 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) + } + + msg, err := server.FractionalBalance(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -80,6 +152,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Remainder_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + 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_Remainder_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Remainder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FractionalBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + 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_FractionalBalance_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FractionalBalance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +259,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Remainder_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_Remainder_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_Remainder_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FractionalBalance_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_FractionalBalance_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_FractionalBalance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_TotalFractionalBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "precisebank", "v1", "total_fractional_balances"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Remainder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"kava", "precisebank", "v1", "remainder"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_FractionalBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"kava", "precisebank", "v1", "fractional_balance", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_TotalFractionalBalances_0 = runtime.ForwardResponseMessage + + forward_Query_Remainder_0 = runtime.ForwardResponseMessage + + forward_Query_FractionalBalance_0 = runtime.ForwardResponseMessage )