From 62d45659b6f72f0820db0ea8156e801b4889011a Mon Sep 17 00:00:00 2001 From: John Letey Date: Mon, 22 Jul 2024 10:42:30 +0200 Subject: [PATCH] refactor: miscellaneous changes --- proto/halo/entitlements/v1/genesis.proto | 2 +- proto/halo/entitlements/v1/query.proto | 36 +- x/halo/client/cli/query_entitlements.go | 47 +- x/halo/client/cli/tx.go | 264 ++++- x/halo/client/cli/tx_entitlements.go | 91 +- x/halo/genesis.go | 8 +- x/halo/keeper/query_server_entitlements.go | 49 +- .../keeper/query_server_entitlements_test.go | 32 - x/halo/keeper/state_entitlements.go | 62 + x/halo/types/entitlements/genesis.pb.go | 62 +- x/halo/types/entitlements/keys.go | 2 +- x/halo/types/entitlements/query.pb.go | 1004 +++++++++++------ x/halo/types/entitlements/query.pb.gw.go | 199 +++- 13 files changed, 1344 insertions(+), 514 deletions(-) diff --git a/proto/halo/entitlements/v1/genesis.proto b/proto/halo/entitlements/v1/genesis.proto index fe0a2f6..80427fd 100644 --- a/proto/halo/entitlements/v1/genesis.proto +++ b/proto/halo/entitlements/v1/genesis.proto @@ -12,7 +12,7 @@ message GenesisState { bool paused = 2; map public_capabilities = 3; repeated RoleCapability role_capabilities = 4 [(gogoproto.nullable) = false]; - repeated UserRole user_roles = 5; + repeated UserRole user_roles = 5 [(gogoproto.nullable) = false]; } // diff --git a/proto/halo/entitlements/v1/query.proto b/proto/halo/entitlements/v1/query.proto index 7a8efd7..8a58af8 100644 --- a/proto/halo/entitlements/v1/query.proto +++ b/proto/halo/entitlements/v1/query.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package halo.entitlements.v1; -import "cosmos/base/query/v1beta1/pagination.proto"; import "google/api/annotations.proto"; +import "halo/entitlements/v1/entitlements.proto"; option go_package = "github.com/noble-assets/halo/x/halo/types/entitlements"; @@ -16,14 +16,17 @@ service Query { option (google.api.http).get = "/halo/entitlements/v1/paused"; } - rpc PublicCapabilities(QueryPublicCapabilities) returns (QueryPublicCapabilitiesResponse) { - option (google.api.http).get = "/halo/entitlements/v1/public_capabilities"; - } rpc PublicCapability(QueryPublicCapability) returns (QueryPublicCapabilityResponse) { option (google.api.http).get = "/halo/entitlements/v1/public_capability/{method}"; } - // TODO: Add missing queries. + rpc RoleCapability(QueryRoleCapability) returns (QueryRoleCapabilityResponse) { + option (google.api.http).get = "/halo/entitlements/v1/role_capability/{method}"; + } + + rpc UserCapability(QueryUserCapability) returns (QueryUserCapabilityResponse) { + option (google.api.http).get = "/halo/entitlements/v1/user_capability/{address}"; + } } // @@ -40,19 +43,26 @@ message QueryPausedResponse { bool paused = 1; } -message QueryPublicCapabilities { - cosmos.base.query.v1beta1.PageRequest pagination = 1; +message QueryPublicCapability { + string method = 1; } -message QueryPublicCapabilitiesResponse { - map public_capabilities = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; +message QueryPublicCapabilityResponse { + bool enabled = 1; } -message QueryPublicCapability { +message QueryRoleCapability { string method = 1; } -message QueryPublicCapabilityResponse { - bool enabled = 1; +message QueryRoleCapabilityResponse { + repeated Role roles = 1; +} + +message QueryUserCapability { + string address = 1; +} + +message QueryUserCapabilityResponse { + repeated Role roles = 1; } diff --git a/x/halo/client/cli/query_entitlements.go b/x/halo/client/cli/query_entitlements.go index 45a1e68..4393eda 100644 --- a/x/halo/client/cli/query_entitlements.go +++ b/x/halo/client/cli/query_entitlements.go @@ -20,8 +20,8 @@ func GetEntitlementsQueryCmd() *cobra.Command { cmd.AddCommand(QueryEntitlementsOwner()) cmd.AddCommand(QueryPaused()) - cmd.AddCommand(QueryPublicCapabilities()) cmd.AddCommand(QueryPublicCapability()) + cmd.AddCommand(QueryRoleCapability()) return cmd } @@ -72,22 +72,42 @@ func QueryPaused() *cobra.Command { return cmd } -func QueryPublicCapabilities() *cobra.Command { +func QueryPublicCapability() *cobra.Command { cmd := &cobra.Command{ - Use: "public-capabilities", - Short: "Query for all public capabilities", - Args: cobra.NoArgs, + Use: "public-capability [method]", + Short: "Query if a method is public", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := entitlements.NewQueryClient(clientCtx) - pagination, err := client.ReadPageRequest(cmd.Flags()) + res, err := queryClient.PublicCapability(context.Background(), &entitlements.QueryPublicCapability{ + Method: args[0], + }) if err != nil { return err } - res, err := queryClient.PublicCapabilities(context.Background(), &entitlements.QueryPublicCapabilities{ - Pagination: pagination, + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func QueryRoleCapability() *cobra.Command { + cmd := &cobra.Command{ + Use: "role-capability [method]", + Short: "Query roles for a specific method", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := entitlements.NewQueryClient(clientCtx) + + res, err := queryClient.RoleCapability(context.Background(), &entitlements.QueryRoleCapability{ + Method: args[0], }) if err != nil { return err @@ -98,22 +118,21 @@ func QueryPublicCapabilities() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "public capabilities") return cmd } -func QueryPublicCapability() *cobra.Command { +func QueryUserCapability() *cobra.Command { cmd := &cobra.Command{ - Use: "public-capability [method]", - Short: "Query if a method is public", + Use: "user-capability [address]", + Short: "Query roles for a specific address", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := entitlements.NewQueryClient(clientCtx) - res, err := queryClient.PublicCapability(context.Background(), &entitlements.QueryPublicCapability{ - Method: args[0], + res, err := queryClient.UserCapability(context.Background(), &entitlements.QueryUserCapability{ + Address: args[0], }) if err != nil { return err diff --git a/x/halo/client/cli/tx.go b/x/halo/client/cli/tx.go index 364b757..b30f1cc 100644 --- a/x/halo/client/cli/tx.go +++ b/x/halo/client/cli/tx.go @@ -1,6 +1,7 @@ package cli import ( + "encoding/base64" "errors" "fmt" @@ -24,10 +25,182 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(GetAggregatorTxCmd()) cmd.AddCommand(GetEntitlementsTxCmd()) - // TODO: Add missing commands. - + cmd.AddCommand(TxDeposit()) + cmd.AddCommand(TxDepositFor()) + cmd.AddCommand(TxWithdraw()) + cmd.AddCommand(TxWithdrawTo()) + cmd.AddCommand(TxWithdrawToAdmin()) cmd.AddCommand(TxBurn()) + cmd.AddCommand(TxBurnFor()) cmd.AddCommand(TxMint()) + cmd.AddCommand(TxTradeToFiat()) + cmd.AddCommand(TxTransferOwnership()) + + return cmd +} + +func TxDeposit() *cobra.Command { + cmd := &cobra.Command{ + Use: "deposit [amount]", + Short: "Deposit a specific amount of underlying assets for USYC", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[0]) + if !ok { + return errors.New("invalid amount") + } + + msg := &types.MsgDeposit{ + Signer: clientCtx.GetFromAddress().String(), + Amount: amount, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func TxDepositFor() *cobra.Command { + cmd := &cobra.Command{ + Use: "deposit-for [recipient] [amount]", + Short: "Deposit a specific amount of underlying assets for USYC, with a recipient", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[1]) + if !ok { + return errors.New("invalid amount") + } + + msg := &types.MsgDepositFor{ + Signer: clientCtx.GetFromAddress().String(), + Recipient: args[0], + Amount: amount, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func TxWithdraw() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw [amount] [signature]", + Short: "Withdraw a specific amount of USYC for underlying assets", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[0]) + if !ok { + return errors.New("invalid amount") + } + + signature, err := base64.StdEncoding.DecodeString(args[1]) + if err != nil { + return err + } + + msg := &types.MsgWithdraw{ + Signer: clientCtx.GetFromAddress().String(), + Amount: amount, + Signature: signature, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func TxWithdrawTo() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw-to [recipient] [amount] [signature]", + Short: "Withdraw a specific amount of USYC for underlying assets, with a recipient", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[1]) + if !ok { + return errors.New("invalid amount") + } + + signature, err := base64.StdEncoding.DecodeString(args[2]) + if err != nil { + return err + } + + msg := &types.MsgWithdrawTo{ + Signer: clientCtx.GetFromAddress().String(), + Recipient: args[0], + Amount: amount, + Signature: signature, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func TxWithdrawToAdmin() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw-to-admin [from] [recipient] [amount]", + Short: "Withdraw a specific amount of USYC as a fund admin", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[2]) + if !ok { + return errors.New("invalid amount") + } + + msg := &types.MsgWithdrawToAdmin{ + Signer: clientCtx.GetFromAddress().String(), + From: args[0], + Recipient: args[1], + Amount: amount, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) return cmd } @@ -62,6 +235,37 @@ func TxBurn() *cobra.Command { return cmd } +func TxBurnFor() *cobra.Command { + cmd := &cobra.Command{ + Use: "burn-for [from] [amount]", + Short: "Transaction that burns tokens from a specific account", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[1]) + if !ok { + return errors.New("invalid amount") + } + + msg := &types.MsgBurnFor{ + Signer: clientCtx.GetFromAddress().String(), + From: args[0], + Amount: amount, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + func TxMint() *cobra.Command { cmd := &cobra.Command{ Use: "mint [to] [amount]", @@ -92,3 +296,59 @@ func TxMint() *cobra.Command { return cmd } + +func TxTradeToFiat() *cobra.Command { + cmd := &cobra.Command{ + Use: "trade-to-fiat [amount] [recipient]", + Short: "Withdraw underlying assets from module as a liquidity provider", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + amount, ok := sdk.NewIntFromString(args[0]) + if !ok { + return errors.New("invalid amount") + } + + msg := &types.MsgTradeToFiat{ + Signer: clientCtx.GetFromAddress().String(), + Amount: amount, + Recipient: args[1], + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func TxTransferOwnership() *cobra.Command { + cmd := &cobra.Command{ + Use: "transfer-ownership [new-owner]", + Short: "Transfer ownership of module", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgTransferOwnership{ + Signer: clientCtx.GetFromAddress().String(), + NewOwner: args[0], + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/halo/client/cli/tx_entitlements.go b/x/halo/client/cli/tx_entitlements.go index 1311891..454a576 100644 --- a/x/halo/client/cli/tx_entitlements.go +++ b/x/halo/client/cli/tx_entitlements.go @@ -20,7 +20,8 @@ func GetEntitlementsTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - // TODO: Add missing commands. + cmd.AddCommand(TxSetPublicCapability()) + cmd.AddCommand(TxSetRoleCapability()) cmd.AddCommand(TxSetUserRole()) cmd.AddCommand(TxPause()) @@ -30,10 +31,85 @@ func GetEntitlementsTxCmd() *cobra.Command { return cmd } +func TxSetPublicCapability() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-public-capability [method] [enabled]", + Short: "Enable or disable a specific public method", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + enabled, _ := strconv.ParseBool(args[1]) + + msg := &entitlements.MsgSetPublicCapability{ + Signer: clientCtx.GetFromAddress().String(), + Method: args[0], + Enabled: enabled, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func TxSetRoleCapability() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-role-capability [role] [method] [enabled]", + Short: "Enable or disable a specific method for a role", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + var role entitlements.Role + switch args[0] { + case "domestic-feeder": + role = entitlements.ROLE_DOMESTIC_FEEDER + case "international-feeder": + role = entitlements.ROLE_INTERNATIONAL_FEEDER + case "domestic-sdyf": + role = entitlements.ROLE_DOMESTIC_SDYF + case "international-sdyf": + role = entitlements.ROLE_INTERNATIONAL_SDYF + case "fund-admin": + role = entitlements.ROLE_FUND_ADMIN + case "liquidity-provider": + role = entitlements.ROLE_LIQUIDITY_PROVIDER + default: + return fmt.Errorf("unknown role: %s", args[0]) + } + + enabled, _ := strconv.ParseBool(args[2]) + + msg := &entitlements.MsgSetRoleCapability{ + Signer: clientCtx.GetFromAddress().String(), + Role: role, + Method: args[1], + Enabled: enabled, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + func TxSetUserRole() *cobra.Command { cmd := &cobra.Command{ Use: "set-user-role [user] [role] [enabled]", - Short: "Transaction that pauses the submodule", + Short: "Enable or disable a specific role for a user", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -43,9 +119,18 @@ func TxSetUserRole() *cobra.Command { var role entitlements.Role switch args[1] { + case "domestic-feeder": + role = entitlements.ROLE_DOMESTIC_FEEDER + case "international-feeder": + role = entitlements.ROLE_INTERNATIONAL_FEEDER + case "domestic-sdyf": + role = entitlements.ROLE_DOMESTIC_SDYF + case "international-sdyf": + role = entitlements.ROLE_INTERNATIONAL_SDYF case "fund-admin": role = entitlements.ROLE_FUND_ADMIN - // TODO: More roles + case "liquidity-provider": + role = entitlements.ROLE_LIQUIDITY_PROVIDER default: return fmt.Errorf("unknown role: %s", args[1]) } diff --git a/x/halo/genesis.go b/x/halo/genesis.go index dbaaab8..a92479f 100644 --- a/x/halo/genesis.go +++ b/x/halo/genesis.go @@ -44,9 +44,11 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *types.GenesisState { Rounds: k.GetRounds(ctx), }, EntitlementsState: entitlements.GenesisState{ - Owner: k.GetEntitlementsOwner(ctx), - Paused: k.GetPaused(ctx), - // TODO + Owner: k.GetEntitlementsOwner(ctx), + Paused: k.GetPaused(ctx), + PublicCapabilities: k.GetPublicCapabilities(ctx), + RoleCapabilities: k.GetAllCapabilityRoles(ctx), + UserRoles: k.GetAllUserRoles(ctx), }, Owner: k.GetOwner(ctx), Nonces: k.GetNonces(ctx), diff --git a/x/halo/keeper/query_server_entitlements.go b/x/halo/keeper/query_server_entitlements.go index 7e7ec7b..f0fcbe4 100644 --- a/x/halo/keeper/query_server_entitlements.go +++ b/x/halo/keeper/query_server_entitlements.go @@ -3,10 +3,8 @@ package keeper import ( "context" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/query" "github.com/noble-assets/halo/x/halo/types/entitlements" ) @@ -44,38 +42,43 @@ func (k entitlementsQueryServer) Paused(goCtx context.Context, req *entitlements }, nil } -func (k entitlementsQueryServer) PublicCapabilities(goCtx context.Context, req *entitlements.QueryPublicCapabilities) (*entitlements.QueryPublicCapabilitiesResponse, error) { - if req == nil { +func (k entitlementsQueryServer) PublicCapability(goCtx context.Context, req *entitlements.QueryPublicCapability) (*entitlements.QueryPublicCapabilityResponse, error) { + if req == nil || req.Method == "" { return nil, errors.ErrInvalidRequest } ctx := sdk.UnwrapSDKContext(goCtx) - store := prefix.NewStore(ctx.KVStore(k.storeKey), entitlements.PublicPrefix) - - publicCapabilities := make(map[string]bool) - pagination, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error { - if len(value) == 1 && value[0] == 1 { - publicCapabilities[string(key)] = true - } else { - publicCapabilities[string(key)] = false - } - return nil - }) - - return &entitlements.QueryPublicCapabilitiesResponse{ - PublicCapabilities: publicCapabilities, - Pagination: pagination, - }, err + + return &entitlements.QueryPublicCapabilityResponse{ + Enabled: k.IsPublicCapability(ctx, req.Method), + }, nil } -func (k entitlementsQueryServer) PublicCapability(goCtx context.Context, req *entitlements.QueryPublicCapability) (*entitlements.QueryPublicCapabilityResponse, error) { +func (k entitlementsQueryServer) RoleCapability(goCtx context.Context, req *entitlements.QueryRoleCapability) (*entitlements.QueryRoleCapabilityResponse, error) { if req == nil || req.Method == "" { return nil, errors.ErrInvalidRequest } ctx := sdk.UnwrapSDKContext(goCtx) - return &entitlements.QueryPublicCapabilityResponse{ - Enabled: k.IsPublicCapability(ctx, req.Method), + return &entitlements.QueryRoleCapabilityResponse{ + Roles: k.GetCapabilityRoles(ctx, req.Method), + }, nil +} + +func (k entitlementsQueryServer) UserCapability(goCtx context.Context, req *entitlements.QueryUserCapability) (*entitlements.QueryUserCapabilityResponse, error) { + if req == nil { + return nil, errors.ErrInvalidRequest + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + address, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, errors.Wrapf(err, "unable to decode address %s", req.Address) + } + + return &entitlements.QueryUserCapabilityResponse{ + Roles: k.GetUserRoles(ctx, address), }, nil } diff --git a/x/halo/keeper/query_server_entitlements_test.go b/x/halo/keeper/query_server_entitlements_test.go index 4c3dd0a..9931d6c 100644 --- a/x/halo/keeper/query_server_entitlements_test.go +++ b/x/halo/keeper/query_server_entitlements_test.go @@ -59,38 +59,6 @@ func TestPausedQuery(t *testing.T) { require.True(t, res.Paused) } -func TestPublicCapabilitiesQuery(t *testing.T) { - // NOTE: Query pagination is assumed working, so isn't testing here. - - k, ctx := mocks.HaloKeeper(t) - goCtx := sdk.WrapSDKContext(ctx) - server := keeper.NewEntitlementsQueryServer(k) - - // ACT: Attempt to query public capabilities with invalid request. - _, err := server.PublicCapabilities(goCtx, nil) - // ASSERT: The query should've failed due to invalid request. - require.ErrorContains(t, err, errors.ErrInvalidRequest.Error()) - - // ACT: Attempt to query public capabilities with no state. - res, err := server.PublicCapabilities(goCtx, &entitlements.QueryPublicCapabilities{}) - // ASSERT: The query should've succeeded, with empty public capabilities. - require.NoError(t, err) - require.Empty(t, res.PublicCapabilities) - - // ARRANGE: Set public capabilities in state. - // NOTE: Depositing will never be public, this is just for testing. - k.SetPublicCapability(ctx, "transfer", false) - k.SetPublicCapability(ctx, "/halo.v1.MsgDeposit", true) - - // ACT: Attempt to query public capabilities with state. - res, err = server.PublicCapabilities(goCtx, &entitlements.QueryPublicCapabilities{}) - // ASSERT: The query should've succeeded, with public capabilities. - require.NoError(t, err) - require.Len(t, res.PublicCapabilities, 2) - require.False(t, res.PublicCapabilities["transfer"]) - require.True(t, res.PublicCapabilities["/halo.v1.MsgDeposit"]) -} - func TestPublicCapabilityQuery(t *testing.T) { k, ctx := mocks.HaloKeeper(t) goCtx := sdk.WrapSDKContext(ctx) diff --git a/x/halo/keeper/state_entitlements.go b/x/halo/keeper/state_entitlements.go index 8ffca60..95edf28 100644 --- a/x/halo/keeper/state_entitlements.go +++ b/x/halo/keeper/state_entitlements.go @@ -71,6 +71,24 @@ func (k *Keeper) IsPublicCapability(ctx sdk.Context, method string) bool { } } +func (k *Keeper) GetPublicCapabilities(ctx sdk.Context) (publicCapabilities map[string]bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), entitlements.PublicPrefix) + itr := store.Iterator(nil, nil) + + defer itr.Close() + + for ; itr.Valid(); itr.Next() { + enabled := false + if len(itr.Value()) == 1 && itr.Value()[0] == 1 { + enabled = true + } + + publicCapabilities[string(itr.Key())] = enabled + } + + return +} + func (k *Keeper) SetPublicCapability(ctx sdk.Context, method string, enabled bool) { store := ctx.KVStore(k.storeKey) key := entitlements.PublicKey(method) @@ -101,6 +119,28 @@ func (k *Keeper) GetCapabilityRoles(ctx sdk.Context, method string) (roles []ent return } +func (k *Keeper) GetAllCapabilityRoles(ctx sdk.Context) (capabilityRoles []entitlements.RoleCapability) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), entitlements.CapabilityPrefix) + itr := store.Iterator(nil, nil) + + defer itr.Close() + + for ; itr.Valid(); itr.Next() { + enabled := false + if len(itr.Value()) == 1 && itr.Value()[0] == 1 { + enabled = true + } + + capabilityRoles = append(capabilityRoles, entitlements.RoleCapability{ + Method: string(itr.Key()[:len(itr.Key())-8]), + Role: entitlements.Role(binary.BigEndian.Uint64(itr.Key()[len(itr.Key())-8:])), + Enabled: enabled, + }) + } + + return +} + func (k *Keeper) SetRoleCapability(ctx sdk.Context, method string, role entitlements.Role, enabled bool) { store := ctx.KVStore(k.storeKey) key := entitlements.CapabilityRoleKey(method, role) @@ -131,6 +171,28 @@ func (k *Keeper) GetUserRoles(ctx sdk.Context, user []byte) (roles []entitlement return } +func (k *Keeper) GetAllUserRoles(ctx sdk.Context) (userRoles []entitlements.UserRole) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), entitlements.UserPrefix) + itr := store.Iterator(nil, nil) + + defer itr.Close() + + for ; itr.Valid(); itr.Next() { + enabled := false + if len(itr.Value()) == 1 && itr.Value()[0] == 1 { + enabled = true + } + + userRoles = append(userRoles, entitlements.UserRole{ + User: sdk.AccAddress(itr.Key()[:len(itr.Key())-8]).String(), + Role: entitlements.Role(binary.BigEndian.Uint64(itr.Key()[len(itr.Key())-8:])), + Enabled: enabled, + }) + } + + return +} + func (k *Keeper) HasRole(ctx sdk.Context, address []byte, role entitlements.Role) bool { store := ctx.KVStore(k.storeKey) bz := store.Get(entitlements.UserRoleKey(address, role)) diff --git a/x/halo/types/entitlements/genesis.pb.go b/x/halo/types/entitlements/genesis.pb.go index f5d8d5f..bc6bf94 100644 --- a/x/halo/types/entitlements/genesis.pb.go +++ b/x/halo/types/entitlements/genesis.pb.go @@ -28,7 +28,7 @@ type GenesisState struct { Paused bool `protobuf:"varint,2,opt,name=paused,proto3" json:"paused,omitempty"` PublicCapabilities map[string]bool `protobuf:"bytes,3,rep,name=public_capabilities,json=publicCapabilities,proto3" json:"public_capabilities,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` RoleCapabilities []RoleCapability `protobuf:"bytes,4,rep,name=role_capabilities,json=roleCapabilities,proto3" json:"role_capabilities"` - UserRoles []*UserRole `protobuf:"bytes,5,rep,name=user_roles,json=userRoles,proto3" json:"user_roles,omitempty"` + UserRoles []UserRole `protobuf:"bytes,5,rep,name=user_roles,json=userRoles,proto3" json:"user_roles"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -92,7 +92,7 @@ func (m *GenesisState) GetRoleCapabilities() []RoleCapability { return nil } -func (m *GenesisState) GetUserRoles() []*UserRole { +func (m *GenesisState) GetUserRoles() []UserRole { if m != nil { return m.UserRoles } @@ -231,34 +231,34 @@ func init() { } var fileDescriptor_8c91c7acafe32b4b = []byte{ - // 422 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0x4e, 0x36, 0xd9, 0x75, 0x77, 0x94, 0x65, 0x1d, 0x8b, 0x86, 0x1c, 0x62, 0x09, 0x82, 0xbd, - 0x38, 0x61, 0x57, 0x10, 0x59, 0xf0, 0xb2, 0xb2, 0x78, 0x2d, 0x11, 0x11, 0xbc, 0x94, 0x49, 0xfb, - 0x48, 0x42, 0xa7, 0x99, 0x30, 0x33, 0xa9, 0xe6, 0x1f, 0x78, 0xf4, 0x67, 0xf5, 0xd8, 0xa3, 0x27, - 0x91, 0xf6, 0x8f, 0xc8, 0x4c, 0x52, 0x49, 0x30, 0xbd, 0x79, 0xca, 0xfb, 0x32, 0xdf, 0xfb, 0xbe, - 0xf7, 0x3e, 0x1e, 0x0a, 0x33, 0xca, 0x78, 0x04, 0x85, 0xca, 0x15, 0x83, 0x15, 0x14, 0x4a, 0x46, - 0xeb, 0xeb, 0x28, 0x85, 0x02, 0x64, 0x2e, 0x49, 0x29, 0xb8, 0xe2, 0x78, 0xa4, 0x39, 0xa4, 0xcb, - 0x21, 0xeb, 0x6b, 0x7f, 0x94, 0xf2, 0x94, 0x1b, 0x42, 0xa4, 0xab, 0x86, 0xeb, 0xbf, 0x1c, 0xd4, - 0xeb, 0xf5, 0x1a, 0x62, 0xf8, 0xdd, 0x41, 0x8f, 0x3e, 0x34, 0x36, 0x1f, 0x15, 0x55, 0x80, 0x47, - 0xe8, 0x94, 0x7f, 0x2d, 0x40, 0x78, 0xf6, 0xd8, 0x9e, 0x5c, 0xc4, 0x0d, 0xc0, 0x4f, 0xd1, 0x59, - 0x49, 0x2b, 0x09, 0x0b, 0xef, 0x64, 0x6c, 0x4f, 0xce, 0xe3, 0x16, 0xe1, 0x25, 0x7a, 0x52, 0x56, - 0x09, 0xcb, 0xe7, 0xb3, 0x39, 0x2d, 0x69, 0x92, 0xb3, 0x5c, 0xe5, 0x20, 0x3d, 0x67, 0xec, 0x4c, - 0x1e, 0xde, 0xdc, 0x92, 0xa1, 0x89, 0x49, 0xd7, 0x8e, 0x4c, 0x4d, 0xf7, 0xfb, 0x4e, 0xf3, 0x7d, - 0xa1, 0x44, 0x1d, 0xe3, 0xf2, 0x9f, 0x07, 0xfc, 0x19, 0x3d, 0x16, 0x9c, 0x41, 0xdf, 0xca, 0x35, - 0x56, 0x2f, 0x86, 0xad, 0x62, 0xce, 0xe0, 0xaf, 0x44, 0x7d, 0xe7, 0x6e, 0x7e, 0x3d, 0xb7, 0xe2, - 0x2b, 0xd1, 0xfd, 0xab, 0x85, 0xdf, 0x21, 0x54, 0x49, 0x10, 0x33, 0xfd, 0x20, 0xbd, 0x53, 0xa3, - 0x18, 0x0c, 0x2b, 0x7e, 0x92, 0x20, 0xb4, 0x6a, 0x7c, 0x51, 0xb5, 0x95, 0xf4, 0xef, 0xd1, 0xb3, - 0x23, 0x6b, 0xe0, 0x2b, 0xe4, 0x2c, 0xa1, 0x6e, 0xb3, 0xd4, 0xa5, 0xce, 0x77, 0x4d, 0x59, 0x05, - 0x6d, 0x90, 0x0d, 0xb8, 0x3d, 0x79, 0x6b, 0x87, 0x02, 0x5d, 0xf6, 0xe7, 0xd5, 0xa9, 0xaf, 0x40, - 0x65, 0x7c, 0xd1, 0x0a, 0xb4, 0x08, 0x13, 0xe4, 0xea, 0x51, 0x8d, 0xc4, 0xe5, 0x8d, 0x7f, 0x7c, - 0xf7, 0xd8, 0xf0, 0xb0, 0x87, 0x1e, 0x40, 0x41, 0x13, 0x06, 0x0b, 0xcf, 0x31, 0xae, 0x07, 0x18, - 0x66, 0xe8, 0xfc, 0xb0, 0x11, 0xc6, 0xc8, 0xd5, 0x3b, 0xb5, 0x5e, 0xa6, 0xfe, 0x7f, 0x4e, 0x77, - 0xd3, 0xcd, 0x2e, 0xb0, 0xb7, 0xbb, 0xc0, 0xfe, 0xbd, 0x0b, 0xec, 0x1f, 0xfb, 0xc0, 0xda, 0xee, - 0x03, 0xeb, 0xe7, 0x3e, 0xb0, 0xbe, 0xbc, 0x49, 0x73, 0x95, 0x55, 0x09, 0x99, 0xf3, 0x55, 0x54, - 0xf0, 0x84, 0xc1, 0x2b, 0x2a, 0x25, 0x28, 0x19, 0x99, 0x1b, 0xfe, 0xd6, 0x7c, 0x54, 0x5d, 0x82, - 0xec, 0x1d, 0x70, 0x72, 0x66, 0x2e, 0xf8, 0xf5, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x2c, - 0xf9, 0x97, 0x3c, 0x03, 0x00, 0x00, + // 421 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0x4e, 0x9a, 0xb4, 0xb6, 0xa3, 0x94, 0x3a, 0x2e, 0x1a, 0x72, 0x88, 0x4b, 0x10, 0xdc, 0x8b, + 0x13, 0x5a, 0x41, 0xa4, 0xc7, 0x96, 0xe2, 0xb5, 0x44, 0x44, 0xf0, 0x52, 0x26, 0xbb, 0x8f, 0x24, + 0x74, 0x36, 0x13, 0x66, 0x26, 0xab, 0xf9, 0x13, 0xe2, 0xcf, 0xea, 0x71, 0x8f, 0x9e, 0x44, 0x76, + 0xff, 0x88, 0xcc, 0x64, 0x56, 0x12, 0xcc, 0xde, 0x3c, 0xe5, 0x7d, 0x99, 0xef, 0x7d, 0xdf, 0x7b, + 0x1f, 0x0f, 0xc5, 0x05, 0x65, 0x3c, 0x81, 0x4a, 0x95, 0x8a, 0xc1, 0x12, 0x2a, 0x25, 0x93, 0xd5, + 0x79, 0x92, 0x43, 0x05, 0xb2, 0x94, 0xa4, 0x16, 0x5c, 0x71, 0x3c, 0xd1, 0x1c, 0xd2, 0xe7, 0x90, + 0xd5, 0x79, 0x38, 0xc9, 0x79, 0xce, 0x0d, 0x21, 0xd1, 0x55, 0xc7, 0x0d, 0x5f, 0x8f, 0xea, 0x0d, + 0x7a, 0x0d, 0x31, 0xfe, 0xee, 0xa1, 0x27, 0x1f, 0x3a, 0x9b, 0x8f, 0x8a, 0x2a, 0xc0, 0x13, 0x74, + 0xc8, 0xbf, 0x56, 0x20, 0x02, 0x77, 0xea, 0xce, 0x4e, 0xd2, 0x0e, 0xe0, 0xe7, 0xe8, 0xa8, 0xa6, + 0x8d, 0x84, 0x45, 0x70, 0x30, 0x75, 0x67, 0xc7, 0xa9, 0x45, 0xf8, 0x1e, 0x3d, 0xab, 0x9b, 0x8c, + 0x95, 0xf3, 0xbb, 0x39, 0xad, 0x69, 0x56, 0xb2, 0x52, 0x95, 0x20, 0x03, 0x6f, 0xea, 0xcd, 0x1e, + 0x5f, 0x5c, 0x92, 0xb1, 0x89, 0x49, 0xdf, 0x8e, 0xdc, 0x9a, 0xee, 0xeb, 0x5e, 0xf3, 0x4d, 0xa5, + 0x44, 0x9b, 0xe2, 0xfa, 0x9f, 0x07, 0xfc, 0x19, 0x3d, 0x15, 0x9c, 0xc1, 0xd0, 0xca, 0x37, 0x56, + 0xaf, 0xc6, 0xad, 0x52, 0xce, 0xe0, 0xaf, 0x44, 0x7b, 0xe5, 0x3f, 0xfc, 0x7a, 0xe9, 0xa4, 0x67, + 0xa2, 0xff, 0x57, 0x0b, 0x5f, 0x23, 0xd4, 0x48, 0x10, 0x77, 0xfa, 0x41, 0x06, 0x87, 0x46, 0x31, + 0x1a, 0x57, 0xfc, 0x24, 0x41, 0x68, 0x55, 0xab, 0x75, 0xd2, 0x58, 0x2c, 0xc3, 0x1b, 0xf4, 0x62, + 0xcf, 0x32, 0xf8, 0x0c, 0x79, 0xf7, 0xd0, 0xda, 0x44, 0x75, 0xa9, 0x53, 0x5e, 0x51, 0xd6, 0x80, + 0x8d, 0xb3, 0x03, 0x97, 0x07, 0xef, 0xdd, 0x58, 0xa0, 0xd3, 0xe1, 0xd4, 0x3a, 0xfb, 0x25, 0xa8, + 0x82, 0x2f, 0xac, 0x80, 0x45, 0x98, 0x20, 0x5f, 0x0f, 0x6c, 0x24, 0x4e, 0x2f, 0xc2, 0xfd, 0x09, + 0xa4, 0x86, 0x87, 0x03, 0xf4, 0x08, 0x2a, 0x9a, 0x31, 0x58, 0x04, 0x9e, 0x71, 0xdd, 0xc1, 0xb8, + 0x40, 0xc7, 0xbb, 0xbd, 0x30, 0x46, 0xbe, 0xde, 0xc9, 0x7a, 0x99, 0xfa, 0xff, 0x39, 0x5d, 0xdd, + 0x3e, 0x6c, 0x22, 0x77, 0xbd, 0x89, 0xdc, 0xdf, 0x9b, 0xc8, 0xfd, 0xb1, 0x8d, 0x9c, 0xf5, 0x36, + 0x72, 0x7e, 0x6e, 0x23, 0xe7, 0xcb, 0xbb, 0xbc, 0x54, 0x45, 0x93, 0x91, 0x39, 0x5f, 0x26, 0x15, + 0xcf, 0x18, 0xbc, 0xa1, 0x52, 0x82, 0x92, 0x89, 0xb9, 0xe4, 0x6f, 0xdd, 0x47, 0xb5, 0x35, 0xc8, + 0xc1, 0x19, 0x67, 0x47, 0xe6, 0x8e, 0xdf, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x39, 0x8a, + 0xf3, 0x42, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -791,7 +791,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UserRoles = append(m.UserRoles, &UserRole{}) + m.UserRoles = append(m.UserRoles, UserRole{}) if err := m.UserRoles[len(m.UserRoles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/halo/types/entitlements/keys.go b/x/halo/types/entitlements/keys.go index b20783d..4795248 100644 --- a/x/halo/types/entitlements/keys.go +++ b/x/halo/types/entitlements/keys.go @@ -7,7 +7,7 @@ const SubmoduleName = "halo-entitlements" var ( OwnerKey = []byte("entitlements/owner") PausedKey = []byte("entitlements/paused") - PublicPrefix = []byte("entitlements/public") + PublicPrefix = []byte("entitlements/public/") CapabilityPrefix = []byte("entitlements/capability/") UserPrefix = []byte("entitlements/user/") ) diff --git a/x/halo/types/entitlements/query.pb.go b/x/halo/types/entitlements/query.pb.go index 6816af8..a0591d7 100644 --- a/x/halo/types/entitlements/query.pb.go +++ b/x/halo/types/entitlements/query.pb.go @@ -6,7 +6,6 @@ package entitlements import ( context "context" fmt "fmt" - query "github.com/cosmos/cosmos-sdk/types/query" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -189,22 +188,22 @@ func (m *QueryPausedResponse) GetPaused() bool { return false } -type QueryPublicCapabilities struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryPublicCapability struct { + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` } -func (m *QueryPublicCapabilities) Reset() { *m = QueryPublicCapabilities{} } -func (m *QueryPublicCapabilities) String() string { return proto.CompactTextString(m) } -func (*QueryPublicCapabilities) ProtoMessage() {} -func (*QueryPublicCapabilities) Descriptor() ([]byte, []int) { +func (m *QueryPublicCapability) Reset() { *m = QueryPublicCapability{} } +func (m *QueryPublicCapability) String() string { return proto.CompactTextString(m) } +func (*QueryPublicCapability) ProtoMessage() {} +func (*QueryPublicCapability) Descriptor() ([]byte, []int) { return fileDescriptor_100425b19d4cf80d, []int{4} } -func (m *QueryPublicCapabilities) XXX_Unmarshal(b []byte) error { +func (m *QueryPublicCapability) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPublicCapabilities) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPublicCapability) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPublicCapabilities.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPublicCapability.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -214,42 +213,41 @@ func (m *QueryPublicCapabilities) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QueryPublicCapabilities) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPublicCapabilities.Merge(m, src) +func (m *QueryPublicCapability) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPublicCapability.Merge(m, src) } -func (m *QueryPublicCapabilities) XXX_Size() int { +func (m *QueryPublicCapability) XXX_Size() int { return m.Size() } -func (m *QueryPublicCapabilities) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPublicCapabilities.DiscardUnknown(m) +func (m *QueryPublicCapability) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPublicCapability.DiscardUnknown(m) } -var xxx_messageInfo_QueryPublicCapabilities proto.InternalMessageInfo +var xxx_messageInfo_QueryPublicCapability proto.InternalMessageInfo -func (m *QueryPublicCapabilities) GetPagination() *query.PageRequest { +func (m *QueryPublicCapability) GetMethod() string { if m != nil { - return m.Pagination + return m.Method } - return nil + return "" } -type QueryPublicCapabilitiesResponse struct { - PublicCapabilities map[string]bool `protobuf:"bytes,1,rep,name=public_capabilities,json=publicCapabilities,proto3" json:"public_capabilities,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryPublicCapabilityResponse struct { + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` } -func (m *QueryPublicCapabilitiesResponse) Reset() { *m = QueryPublicCapabilitiesResponse{} } -func (m *QueryPublicCapabilitiesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPublicCapabilitiesResponse) ProtoMessage() {} -func (*QueryPublicCapabilitiesResponse) Descriptor() ([]byte, []int) { +func (m *QueryPublicCapabilityResponse) Reset() { *m = QueryPublicCapabilityResponse{} } +func (m *QueryPublicCapabilityResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPublicCapabilityResponse) ProtoMessage() {} +func (*QueryPublicCapabilityResponse) Descriptor() ([]byte, []int) { return fileDescriptor_100425b19d4cf80d, []int{5} } -func (m *QueryPublicCapabilitiesResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPublicCapabilityResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPublicCapabilitiesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPublicCapabilityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPublicCapabilitiesResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPublicCapabilityResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -259,48 +257,129 @@ func (m *QueryPublicCapabilitiesResponse) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } -func (m *QueryPublicCapabilitiesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPublicCapabilitiesResponse.Merge(m, src) +func (m *QueryPublicCapabilityResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPublicCapabilityResponse.Merge(m, src) } -func (m *QueryPublicCapabilitiesResponse) XXX_Size() int { +func (m *QueryPublicCapabilityResponse) XXX_Size() int { return m.Size() } -func (m *QueryPublicCapabilitiesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPublicCapabilitiesResponse.DiscardUnknown(m) +func (m *QueryPublicCapabilityResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPublicCapabilityResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryPublicCapabilitiesResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPublicCapabilityResponse proto.InternalMessageInfo -func (m *QueryPublicCapabilitiesResponse) GetPublicCapabilities() map[string]bool { +func (m *QueryPublicCapabilityResponse) GetEnabled() bool { if m != nil { - return m.PublicCapabilities + return m.Enabled } - return nil + return false +} + +type QueryRoleCapability struct { + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` +} + +func (m *QueryRoleCapability) Reset() { *m = QueryRoleCapability{} } +func (m *QueryRoleCapability) String() string { return proto.CompactTextString(m) } +func (*QueryRoleCapability) ProtoMessage() {} +func (*QueryRoleCapability) Descriptor() ([]byte, []int) { + return fileDescriptor_100425b19d4cf80d, []int{6} +} +func (m *QueryRoleCapability) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRoleCapability) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRoleCapability.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 *QueryRoleCapability) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRoleCapability.Merge(m, src) +} +func (m *QueryRoleCapability) XXX_Size() int { + return m.Size() +} +func (m *QueryRoleCapability) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRoleCapability.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRoleCapability proto.InternalMessageInfo + +func (m *QueryRoleCapability) GetMethod() string { + if m != nil { + return m.Method + } + return "" +} + +type QueryRoleCapabilityResponse struct { + Roles []Role `protobuf:"varint,1,rep,packed,name=roles,proto3,enum=halo.entitlements.v1.Role" json:"roles,omitempty"` +} + +func (m *QueryRoleCapabilityResponse) Reset() { *m = QueryRoleCapabilityResponse{} } +func (m *QueryRoleCapabilityResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRoleCapabilityResponse) ProtoMessage() {} +func (*QueryRoleCapabilityResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_100425b19d4cf80d, []int{7} +} +func (m *QueryRoleCapabilityResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRoleCapabilityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRoleCapabilityResponse.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 *QueryRoleCapabilityResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRoleCapabilityResponse.Merge(m, src) +} +func (m *QueryRoleCapabilityResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRoleCapabilityResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRoleCapabilityResponse.DiscardUnknown(m) } -func (m *QueryPublicCapabilitiesResponse) GetPagination() *query.PageResponse { +var xxx_messageInfo_QueryRoleCapabilityResponse proto.InternalMessageInfo + +func (m *QueryRoleCapabilityResponse) GetRoles() []Role { if m != nil { - return m.Pagination + return m.Roles } return nil } -type QueryPublicCapability struct { - Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` +type QueryUserCapability struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } -func (m *QueryPublicCapability) Reset() { *m = QueryPublicCapability{} } -func (m *QueryPublicCapability) String() string { return proto.CompactTextString(m) } -func (*QueryPublicCapability) ProtoMessage() {} -func (*QueryPublicCapability) Descriptor() ([]byte, []int) { - return fileDescriptor_100425b19d4cf80d, []int{6} +func (m *QueryUserCapability) Reset() { *m = QueryUserCapability{} } +func (m *QueryUserCapability) String() string { return proto.CompactTextString(m) } +func (*QueryUserCapability) ProtoMessage() {} +func (*QueryUserCapability) Descriptor() ([]byte, []int) { + return fileDescriptor_100425b19d4cf80d, []int{8} } -func (m *QueryPublicCapability) XXX_Unmarshal(b []byte) error { +func (m *QueryUserCapability) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPublicCapability) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryUserCapability) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPublicCapability.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryUserCapability.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -310,41 +389,41 @@ func (m *QueryPublicCapability) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *QueryPublicCapability) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPublicCapability.Merge(m, src) +func (m *QueryUserCapability) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUserCapability.Merge(m, src) } -func (m *QueryPublicCapability) XXX_Size() int { +func (m *QueryUserCapability) XXX_Size() int { return m.Size() } -func (m *QueryPublicCapability) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPublicCapability.DiscardUnknown(m) +func (m *QueryUserCapability) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUserCapability.DiscardUnknown(m) } -var xxx_messageInfo_QueryPublicCapability proto.InternalMessageInfo +var xxx_messageInfo_QueryUserCapability proto.InternalMessageInfo -func (m *QueryPublicCapability) GetMethod() string { +func (m *QueryUserCapability) GetAddress() string { if m != nil { - return m.Method + return m.Address } return "" } -type QueryPublicCapabilityResponse struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` +type QueryUserCapabilityResponse struct { + Roles []Role `protobuf:"varint,1,rep,packed,name=roles,proto3,enum=halo.entitlements.v1.Role" json:"roles,omitempty"` } -func (m *QueryPublicCapabilityResponse) Reset() { *m = QueryPublicCapabilityResponse{} } -func (m *QueryPublicCapabilityResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPublicCapabilityResponse) ProtoMessage() {} -func (*QueryPublicCapabilityResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_100425b19d4cf80d, []int{7} +func (m *QueryUserCapabilityResponse) Reset() { *m = QueryUserCapabilityResponse{} } +func (m *QueryUserCapabilityResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUserCapabilityResponse) ProtoMessage() {} +func (*QueryUserCapabilityResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_100425b19d4cf80d, []int{9} } -func (m *QueryPublicCapabilityResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryUserCapabilityResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPublicCapabilityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryUserCapabilityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPublicCapabilityResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryUserCapabilityResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -354,23 +433,23 @@ func (m *QueryPublicCapabilityResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryPublicCapabilityResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPublicCapabilityResponse.Merge(m, src) +func (m *QueryUserCapabilityResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUserCapabilityResponse.Merge(m, src) } -func (m *QueryPublicCapabilityResponse) XXX_Size() int { +func (m *QueryUserCapabilityResponse) XXX_Size() int { return m.Size() } -func (m *QueryPublicCapabilityResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPublicCapabilityResponse.DiscardUnknown(m) +func (m *QueryUserCapabilityResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUserCapabilityResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryPublicCapabilityResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryUserCapabilityResponse proto.InternalMessageInfo -func (m *QueryPublicCapabilityResponse) GetEnabled() bool { +func (m *QueryUserCapabilityResponse) GetRoles() []Role { if m != nil { - return m.Enabled + return m.Roles } - return false + return nil } func init() { @@ -378,53 +457,51 @@ func init() { proto.RegisterType((*QueryOwnerResponse)(nil), "halo.entitlements.v1.QueryOwnerResponse") proto.RegisterType((*QueryPaused)(nil), "halo.entitlements.v1.QueryPaused") proto.RegisterType((*QueryPausedResponse)(nil), "halo.entitlements.v1.QueryPausedResponse") - proto.RegisterType((*QueryPublicCapabilities)(nil), "halo.entitlements.v1.QueryPublicCapabilities") - proto.RegisterType((*QueryPublicCapabilitiesResponse)(nil), "halo.entitlements.v1.QueryPublicCapabilitiesResponse") - proto.RegisterMapType((map[string]bool)(nil), "halo.entitlements.v1.QueryPublicCapabilitiesResponse.PublicCapabilitiesEntry") proto.RegisterType((*QueryPublicCapability)(nil), "halo.entitlements.v1.QueryPublicCapability") proto.RegisterType((*QueryPublicCapabilityResponse)(nil), "halo.entitlements.v1.QueryPublicCapabilityResponse") + proto.RegisterType((*QueryRoleCapability)(nil), "halo.entitlements.v1.QueryRoleCapability") + proto.RegisterType((*QueryRoleCapabilityResponse)(nil), "halo.entitlements.v1.QueryRoleCapabilityResponse") + proto.RegisterType((*QueryUserCapability)(nil), "halo.entitlements.v1.QueryUserCapability") + proto.RegisterType((*QueryUserCapabilityResponse)(nil), "halo.entitlements.v1.QueryUserCapabilityResponse") } func init() { proto.RegisterFile("halo/entitlements/v1/query.proto", fileDescriptor_100425b19d4cf80d) } var fileDescriptor_100425b19d4cf80d = []byte{ - // 578 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xae, 0x53, 0x1a, 0xca, 0x04, 0xa4, 0x6a, 0x5b, 0x68, 0x64, 0x5a, 0x13, 0x0c, 0x82, 0xb4, - 0x55, 0xbc, 0x24, 0x15, 0xa8, 0x70, 0x04, 0x15, 0x4e, 0x88, 0xe0, 0x23, 0x17, 0xb4, 0x4e, 0x47, - 0x89, 0x85, 0xe3, 0x75, 0xb3, 0xeb, 0x50, 0x8b, 0x9f, 0x03, 0x4f, 0x80, 0xc4, 0x73, 0x80, 0xc4, - 0x5b, 0x70, 0xac, 0xc4, 0x85, 0x63, 0x95, 0xf0, 0x20, 0xc8, 0xbb, 0xa9, 0x9b, 0x2a, 0x4e, 0xd3, - 0x72, 0x4a, 0x66, 0xe7, 0x9b, 0xfd, 0xe6, 0xdb, 0xf9, 0xc6, 0x50, 0xe9, 0xb0, 0x80, 0x53, 0x0c, - 0xa5, 0x2f, 0x03, 0xec, 0x62, 0x28, 0x05, 0xed, 0xd7, 0xe9, 0x7e, 0x8c, 0xbd, 0xc4, 0x89, 0x7a, - 0x5c, 0x72, 0xb2, 0x92, 0x22, 0x9c, 0x71, 0x84, 0xd3, 0xaf, 0x9b, 0x9b, 0x2d, 0x2e, 0xba, 0x5c, - 0x50, 0x8f, 0x09, 0xd4, 0x70, 0xda, 0xaf, 0x7b, 0x28, 0x59, 0x9d, 0x46, 0xac, 0xed, 0x87, 0x4c, - 0xfa, 0x3c, 0xd4, 0x37, 0x98, 0x6b, 0x6d, 0xce, 0xdb, 0x01, 0x52, 0x16, 0xf9, 0x94, 0x85, 0x21, - 0x97, 0x2a, 0x29, 0x74, 0xd6, 0xbe, 0x0a, 0xf0, 0x3a, 0xad, 0x7f, 0xf5, 0x3e, 0xc4, 0x9e, 0xbd, - 0x09, 0xe4, 0x24, 0x72, 0x51, 0x44, 0x3c, 0x14, 0x48, 0x56, 0x60, 0x81, 0xa7, 0x07, 0x65, 0xa3, - 0x62, 0x54, 0xaf, 0xb8, 0x3a, 0xb0, 0xaf, 0x41, 0x49, 0x61, 0x9b, 0x2c, 0x16, 0xb8, 0x67, 0xd7, - 0x60, 0x79, 0x2c, 0xcc, 0x6a, 0x6f, 0x40, 0x31, 0x52, 0x27, 0xaa, 0x78, 0xd1, 0x1d, 0x45, 0x36, - 0x83, 0x55, 0x0d, 0x8f, 0xbd, 0xc0, 0x6f, 0x3d, 0x63, 0x11, 0xf3, 0xfc, 0xc0, 0x97, 0x3e, 0x0a, - 0xf2, 0x1c, 0xe0, 0x44, 0x84, 0x2a, 0x2b, 0x35, 0xee, 0x39, 0x5a, 0xb1, 0x93, 0x2a, 0x76, 0xf4, - 0x03, 0x8d, 0x14, 0x3b, 0x4d, 0xd6, 0x46, 0x17, 0xf7, 0x63, 0x14, 0xd2, 0x1d, 0xab, 0xb4, 0x7f, - 0x16, 0xe0, 0xd6, 0x14, 0x8e, 0xac, 0xbd, 0xcf, 0xb0, 0x1c, 0xa9, 0xec, 0xdb, 0xd6, 0x58, 0xba, - 0x6c, 0x54, 0xe6, 0xab, 0xa5, 0xc6, 0x4b, 0x27, 0xef, 0xf1, 0x9d, 0x19, 0x77, 0x3a, 0x93, 0xa9, - 0xdd, 0x50, 0xf6, 0x12, 0x97, 0x44, 0x93, 0x5a, 0x5f, 0x9c, 0xd2, 0x5a, 0x50, 0x5a, 0xef, 0xcf, - 0xd4, 0xaa, 0x89, 0xc6, 0xc5, 0x9a, 0xbb, 0xb0, 0x3a, 0x85, 0x97, 0x2c, 0xc1, 0xfc, 0x3b, 0x4c, - 0x46, 0xc3, 0x4b, 0xff, 0xa6, 0x03, 0xed, 0xb3, 0x20, 0x46, 0x45, 0xb8, 0xe8, 0xea, 0xe0, 0x49, - 0x61, 0xc7, 0xb0, 0x29, 0x5c, 0xcf, 0x93, 0x97, 0xa4, 0x73, 0xec, 0xa2, 0xec, 0xf0, 0xbd, 0xd1, - 0x3d, 0xa3, 0xc8, 0x7e, 0x0c, 0xeb, 0xb9, 0x05, 0xd9, 0x0b, 0x97, 0xe1, 0x32, 0x86, 0xcc, 0x0b, - 0x32, 0x07, 0x1c, 0x87, 0x8d, 0xa3, 0x4b, 0xb0, 0xa0, 0x6a, 0xc9, 0x01, 0x2c, 0x28, 0xc7, 0x91, - 0xca, 0x19, 0x2f, 0xae, 0x10, 0x66, 0x75, 0x16, 0xe2, 0x98, 0xd8, 0xbe, 0xf3, 0xe5, 0xf7, 0xdf, - 0x6f, 0x85, 0x75, 0x72, 0x93, 0xe6, 0x2e, 0x99, 0x32, 0x31, 0xf9, 0x08, 0x45, 0x6d, 0x58, 0x72, - 0xfb, 0xac, 0x61, 0x2b, 0x88, 0xb9, 0x31, 0x13, 0x92, 0x91, 0xdf, 0x55, 0xe4, 0x16, 0x59, 0xcb, - 0x27, 0xd7, 0x4b, 0x40, 0xbe, 0x1b, 0x40, 0x72, 0x16, 0xa0, 0x76, 0x21, 0xdf, 0x99, 0x0f, 0xff, - 0xcb, 0xa6, 0x76, 0x5d, 0xb5, 0xb8, 0x45, 0x36, 0xa6, 0xb4, 0x38, 0xb9, 0x16, 0xe4, 0x87, 0x01, - 0x4b, 0x13, 0xce, 0xd8, 0x3a, 0x3f, 0x7d, 0x62, 0x6e, 0x5f, 0x00, 0x9c, 0x75, 0xba, 0xa3, 0x3a, - 0x6d, 0x90, 0x07, 0xe7, 0xeb, 0x34, 0xa1, 0x1f, 0xb4, 0x39, 0x3f, 0x3d, 0x6d, 0xfe, 0x1a, 0x58, - 0xc6, 0xe1, 0xc0, 0x32, 0x8e, 0x06, 0x96, 0xf1, 0x75, 0x68, 0xcd, 0x1d, 0x0e, 0xad, 0xb9, 0x3f, - 0x43, 0x6b, 0xee, 0xcd, 0xa3, 0xb6, 0x2f, 0x3b, 0xb1, 0xe7, 0xb4, 0x78, 0x97, 0x86, 0xdc, 0x0b, - 0xb0, 0xc6, 0x84, 0x40, 0x29, 0x34, 0xc5, 0x81, 0xfe, 0x91, 0x49, 0x84, 0xe2, 0x14, 0x9f, 0x57, - 0x54, 0x9f, 0xcd, 0xed, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x2d, 0x7f, 0xa3, 0xba, 0x05, + // 530 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x1c, 0xc6, 0x1b, 0x50, 0x3b, 0xf8, 0x03, 0x15, 0x32, 0x03, 0x55, 0xd9, 0x16, 0x95, 0x80, 0x44, + 0x01, 0x2d, 0x6e, 0x3b, 0x69, 0xc0, 0x15, 0x1e, 0x60, 0x23, 0x12, 0x17, 0x2e, 0xc8, 0x69, 0xad, + 0x36, 0x52, 0x1a, 0x87, 0xd8, 0x19, 0xab, 0x60, 0x17, 0x78, 0x01, 0x24, 0xde, 0x01, 0x6e, 0x3c, + 0x07, 0xc7, 0x49, 0x5c, 0x38, 0xa2, 0x96, 0x07, 0x41, 0xb1, 0x53, 0xaf, 0x29, 0x26, 0x2b, 0x9c, + 0xa2, 0xbf, 0xf5, 0x7d, 0xff, 0xef, 0xa7, 0xf8, 0x4b, 0xa0, 0x3d, 0x26, 0x11, 0xc3, 0x34, 0x16, + 0xa1, 0x88, 0xe8, 0x84, 0xc6, 0x82, 0xe3, 0xa3, 0x1e, 0x7e, 0x9d, 0xd1, 0x74, 0xea, 0x25, 0x29, + 0x13, 0x0c, 0x6d, 0xe6, 0x0a, 0x6f, 0x59, 0xe1, 0x1d, 0xf5, 0xec, 0xed, 0x11, 0x63, 0xa3, 0x88, + 0x62, 0x92, 0x84, 0x98, 0xc4, 0x31, 0x13, 0x44, 0x84, 0x2c, 0xe6, 0xca, 0x63, 0xdf, 0x33, 0x6e, + 0x2d, 0xed, 0x90, 0x42, 0xf7, 0x2a, 0xc0, 0xf3, 0x3c, 0xeb, 0xe0, 0x4d, 0x4c, 0x53, 0xf7, 0x01, + 0xa0, 0xb3, 0xc9, 0xa7, 0x3c, 0x61, 0x31, 0xa7, 0x68, 0x13, 0xea, 0x2c, 0x3f, 0x68, 0x59, 0x6d, + 0xab, 0x73, 0xd9, 0x57, 0x83, 0x7b, 0x0d, 0xae, 0x48, 0xed, 0x21, 0xc9, 0x38, 0x1d, 0xba, 0xbb, + 0x70, 0x63, 0x69, 0xd4, 0xde, 0x5b, 0xd0, 0x48, 0xe4, 0x89, 0x34, 0x5f, 0xf2, 0x8b, 0xc9, 0xc5, + 0x70, 0x53, 0xc9, 0xb3, 0x20, 0x0a, 0x07, 0xcf, 0x48, 0x42, 0x82, 0x30, 0x0a, 0xc5, 0x34, 0x37, + 0x4c, 0xa8, 0x18, 0xb3, 0x61, 0x91, 0x56, 0x4c, 0xee, 0x13, 0xd8, 0x31, 0x1a, 0x74, 0x52, 0x0b, + 0x36, 0x68, 0x4c, 0x82, 0x48, 0x47, 0x2d, 0x46, 0x8d, 0xe6, 0xb3, 0x88, 0xae, 0x91, 0x74, 0x00, + 0x5b, 0x06, 0xb9, 0xce, 0xe9, 0x42, 0x3d, 0x65, 0x11, 0xe5, 0x2d, 0xab, 0x7d, 0xb1, 0xd3, 0xec, + 0xdb, 0x9e, 0xe9, 0x7a, 0xbc, 0xdc, 0xec, 0x2b, 0xa1, 0x8b, 0x8b, 0xfc, 0x17, 0x9c, 0xa6, 0x4b, + 0xf9, 0x2d, 0xd8, 0x20, 0xc3, 0x61, 0x4a, 0x39, 0x2f, 0x00, 0x16, 0xa3, 0x26, 0x28, 0x1b, 0xfe, + 0x9f, 0xa0, 0xff, 0xa1, 0x01, 0x75, 0xb9, 0x11, 0x1d, 0x43, 0x5d, 0x5e, 0x2e, 0x6a, 0x9b, 0x5d, + 0x67, 0xd7, 0x6f, 0x77, 0xce, 0x53, 0x2c, 0x80, 0xdc, 0x3b, 0xef, 0xbf, 0xff, 0xfa, 0x74, 0x61, + 0x07, 0x6d, 0x61, 0x63, 0xed, 0x64, 0x5f, 0xd0, 0x3b, 0x68, 0xa8, 0x6e, 0xa0, 0xdb, 0x15, 0x8b, + 0x95, 0xc4, 0xbe, 0x7f, 0xae, 0x44, 0x87, 0xdf, 0x95, 0xe1, 0x0e, 0xda, 0x36, 0x87, 0xab, 0xbe, + 0xa1, 0xaf, 0x16, 0x5c, 0xff, 0xa3, 0x6b, 0x0f, 0xab, 0x52, 0x56, 0xc4, 0xf6, 0xde, 0x3f, 0x88, + 0x35, 0xdc, 0x63, 0x09, 0xd7, 0x47, 0xdd, 0xbf, 0xc0, 0x49, 0xdf, 0xab, 0x81, 0x36, 0xe2, 0xb7, + 0xaa, 0x84, 0x27, 0xe8, 0xb3, 0x05, 0xcd, 0x95, 0xc2, 0x56, 0xbd, 0x94, 0xb2, 0xd4, 0xee, 0xad, + 0x2d, 0xd5, 0xa8, 0xfb, 0x12, 0xb5, 0x8b, 0x3c, 0x33, 0x6a, 0x5e, 0x24, 0x23, 0xe8, 0x17, 0x0b, + 0x9a, 0x2b, 0xcd, 0xae, 0x02, 0x2d, 0x4b, 0x2b, 0x41, 0xcd, 0xf5, 0x77, 0x1f, 0x49, 0xd0, 0x1e, + 0xc2, 0x66, 0xd0, 0x8c, 0xd3, 0xb4, 0x04, 0x5a, 0x7c, 0x55, 0x27, 0x4f, 0x0f, 0xbf, 0xcd, 0x1c, + 0xeb, 0x74, 0xe6, 0x58, 0x3f, 0x67, 0x8e, 0xf5, 0x71, 0xee, 0xd4, 0x4e, 0xe7, 0x4e, 0xed, 0xc7, + 0xdc, 0xa9, 0xbd, 0xdc, 0x1f, 0x85, 0x62, 0x9c, 0x05, 0xde, 0x80, 0x4d, 0x70, 0xcc, 0x82, 0x88, + 0xee, 0x12, 0xce, 0xa9, 0xe0, 0x2a, 0xe1, 0x58, 0x3d, 0xc4, 0x34, 0xa1, 0xbc, 0x14, 0x17, 0x34, + 0xe4, 0x4f, 0x74, 0xef, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x95, 0x29, 0x1f, 0xc5, 0x05, 0x00, 0x00, } @@ -442,8 +519,9 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { Owner(ctx context.Context, in *QueryOwner, opts ...grpc.CallOption) (*QueryOwnerResponse, error) Paused(ctx context.Context, in *QueryPaused, opts ...grpc.CallOption) (*QueryPausedResponse, error) - PublicCapabilities(ctx context.Context, in *QueryPublicCapabilities, opts ...grpc.CallOption) (*QueryPublicCapabilitiesResponse, error) PublicCapability(ctx context.Context, in *QueryPublicCapability, opts ...grpc.CallOption) (*QueryPublicCapabilityResponse, error) + RoleCapability(ctx context.Context, in *QueryRoleCapability, opts ...grpc.CallOption) (*QueryRoleCapabilityResponse, error) + UserCapability(ctx context.Context, in *QueryUserCapability, opts ...grpc.CallOption) (*QueryUserCapabilityResponse, error) } type queryClient struct { @@ -472,18 +550,27 @@ func (c *queryClient) Paused(ctx context.Context, in *QueryPaused, opts ...grpc. return out, nil } -func (c *queryClient) PublicCapabilities(ctx context.Context, in *QueryPublicCapabilities, opts ...grpc.CallOption) (*QueryPublicCapabilitiesResponse, error) { - out := new(QueryPublicCapabilitiesResponse) - err := c.cc.Invoke(ctx, "/halo.entitlements.v1.Query/PublicCapabilities", in, out, opts...) +func (c *queryClient) PublicCapability(ctx context.Context, in *QueryPublicCapability, opts ...grpc.CallOption) (*QueryPublicCapabilityResponse, error) { + out := new(QueryPublicCapabilityResponse) + err := c.cc.Invoke(ctx, "/halo.entitlements.v1.Query/PublicCapability", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RoleCapability(ctx context.Context, in *QueryRoleCapability, opts ...grpc.CallOption) (*QueryRoleCapabilityResponse, error) { + out := new(QueryRoleCapabilityResponse) + err := c.cc.Invoke(ctx, "/halo.entitlements.v1.Query/RoleCapability", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) PublicCapability(ctx context.Context, in *QueryPublicCapability, opts ...grpc.CallOption) (*QueryPublicCapabilityResponse, error) { - out := new(QueryPublicCapabilityResponse) - err := c.cc.Invoke(ctx, "/halo.entitlements.v1.Query/PublicCapability", in, out, opts...) +func (c *queryClient) UserCapability(ctx context.Context, in *QueryUserCapability, opts ...grpc.CallOption) (*QueryUserCapabilityResponse, error) { + out := new(QueryUserCapabilityResponse) + err := c.cc.Invoke(ctx, "/halo.entitlements.v1.Query/UserCapability", in, out, opts...) if err != nil { return nil, err } @@ -494,8 +581,9 @@ func (c *queryClient) PublicCapability(ctx context.Context, in *QueryPublicCapab type QueryServer interface { Owner(context.Context, *QueryOwner) (*QueryOwnerResponse, error) Paused(context.Context, *QueryPaused) (*QueryPausedResponse, error) - PublicCapabilities(context.Context, *QueryPublicCapabilities) (*QueryPublicCapabilitiesResponse, error) PublicCapability(context.Context, *QueryPublicCapability) (*QueryPublicCapabilityResponse, error) + RoleCapability(context.Context, *QueryRoleCapability) (*QueryRoleCapabilityResponse, error) + UserCapability(context.Context, *QueryUserCapability) (*QueryUserCapabilityResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -508,12 +596,15 @@ func (*UnimplementedQueryServer) Owner(ctx context.Context, req *QueryOwner) (*Q func (*UnimplementedQueryServer) Paused(ctx context.Context, req *QueryPaused) (*QueryPausedResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Paused not implemented") } -func (*UnimplementedQueryServer) PublicCapabilities(ctx context.Context, req *QueryPublicCapabilities) (*QueryPublicCapabilitiesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PublicCapabilities not implemented") -} func (*UnimplementedQueryServer) PublicCapability(ctx context.Context, req *QueryPublicCapability) (*QueryPublicCapabilityResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PublicCapability not implemented") } +func (*UnimplementedQueryServer) RoleCapability(ctx context.Context, req *QueryRoleCapability) (*QueryRoleCapabilityResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RoleCapability not implemented") +} +func (*UnimplementedQueryServer) UserCapability(ctx context.Context, req *QueryUserCapability) (*QueryUserCapabilityResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UserCapability not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -555,38 +646,56 @@ func _Query_Paused_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_PublicCapabilities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPublicCapabilities) +func _Query_PublicCapability_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPublicCapability) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).PublicCapabilities(ctx, in) + return srv.(QueryServer).PublicCapability(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/halo.entitlements.v1.Query/PublicCapabilities", + FullMethod: "/halo.entitlements.v1.Query/PublicCapability", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PublicCapabilities(ctx, req.(*QueryPublicCapabilities)) + return srv.(QueryServer).PublicCapability(ctx, req.(*QueryPublicCapability)) } return interceptor(ctx, in, info, handler) } -func _Query_PublicCapability_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPublicCapability) +func _Query_RoleCapability_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRoleCapability) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).PublicCapability(ctx, in) + return srv.(QueryServer).RoleCapability(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/halo.entitlements.v1.Query/PublicCapability", + FullMethod: "/halo.entitlements.v1.Query/RoleCapability", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PublicCapability(ctx, req.(*QueryPublicCapability)) + return srv.(QueryServer).RoleCapability(ctx, req.(*QueryRoleCapability)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_UserCapability_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUserCapability) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).UserCapability(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/halo.entitlements.v1.Query/UserCapability", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).UserCapability(ctx, req.(*QueryUserCapability)) } return interceptor(ctx, in, info, handler) } @@ -603,14 +712,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Paused", Handler: _Query_Paused_Handler, }, - { - MethodName: "PublicCapabilities", - Handler: _Query_PublicCapabilities_Handler, - }, { MethodName: "PublicCapability", Handler: _Query_PublicCapability_Handler, }, + { + MethodName: "RoleCapability", + Handler: _Query_RoleCapability_Handler, + }, + { + MethodName: "UserCapability", + Handler: _Query_UserCapability_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "halo/entitlements/v1/query.proto", @@ -725,7 +838,7 @@ func (m *QueryPausedResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryPublicCapabilities) Marshal() (dAtA []byte, err error) { +func (m *QueryPublicCapability) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -735,32 +848,27 @@ func (m *QueryPublicCapabilities) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPublicCapabilities) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPublicCapability) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPublicCapabilities) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPublicCapability) 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)) - } + if len(m.Method) > 0 { + i -= len(m.Method) + copy(dAtA[i:], m.Method) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Method))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPublicCapabilitiesResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPublicCapabilityResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -770,54 +878,30 @@ func (m *QueryPublicCapabilitiesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPublicCapabilitiesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPublicCapabilityResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPublicCapabilitiesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPublicCapabilityResponse) 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)) - } + if m.Enabled { i-- - dAtA[i] = 0x12 - } - if len(m.PublicCapabilities) > 0 { - for k := range m.PublicCapabilities { - v := m.PublicCapabilities[k] - baseI := i - i-- - if v { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintQuery(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 } + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QueryPublicCapability) Marshal() (dAtA []byte, err error) { +func (m *QueryRoleCapability) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -827,12 +911,12 @@ func (m *QueryPublicCapability) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPublicCapability) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRoleCapability) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPublicCapability) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRoleCapability) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -847,7 +931,7 @@ func (m *QueryPublicCapability) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryPublicCapabilityResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryRoleCapabilityResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -857,25 +941,104 @@ func (m *QueryPublicCapabilityResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPublicCapabilityResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRoleCapabilityResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPublicCapabilityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRoleCapabilityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Enabled { + if len(m.Roles) > 0 { + dAtA2 := make([]byte, len(m.Roles)*10) + var j1 int + for _, num := range m.Roles { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintQuery(dAtA, i, uint64(j1)) i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUserCapability) 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 *QueryUserCapability) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUserCapability) 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 *QueryUserCapabilityResponse) 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 *QueryUserCapabilityResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUserCapabilityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Roles) > 0 { + dAtA4 := make([]byte, len(m.Roles)*10) + var j3 int + for _, num := range m.Roles { + for num >= 1<<7 { + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA4[j3] = uint8(num) + j3++ } + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintQuery(dAtA, i, uint64(j3)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -934,61 +1097,85 @@ func (m *QueryPausedResponse) Size() (n int) { return n } -func (m *QueryPublicCapabilities) Size() (n int) { +func (m *QueryPublicCapability) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Pagination != nil { - l = m.Pagination.Size() + l = len(m.Method) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryPublicCapabilitiesResponse) Size() (n int) { +func (m *QueryPublicCapabilityResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.PublicCapabilities) > 0 { - for k, v := range m.PublicCapabilities { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + 1 + 1 - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) - } + if m.Enabled { + n += 2 } - if m.Pagination != nil { - l = m.Pagination.Size() + return n +} + +func (m *QueryRoleCapability) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Method) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryPublicCapability) Size() (n int) { +func (m *QueryRoleCapabilityResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Method) + if len(m.Roles) > 0 { + l = 0 + for _, e := range m.Roles { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l + } + return n +} + +func (m *QueryUserCapability) 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 *QueryPublicCapabilityResponse) Size() (n int) { +func (m *QueryUserCapabilityResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Enabled { - n += 2 + if len(m.Roles) > 0 { + l = 0 + for _, e := range m.Roles { + l += sovQuery(uint64(e)) + } + n += 1 + sovQuery(uint64(l)) + l } return n } @@ -1251,7 +1438,7 @@ func (m *QueryPausedResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPublicCapabilities) Unmarshal(dAtA []byte) error { +func (m *QueryPublicCapability) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1274,17 +1461,17 @@ func (m *QueryPublicCapabilities) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPublicCapabilities: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPublicCapability: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPublicCapabilities: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPublicCapability: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1294,28 +1481,94 @@ func (m *QueryPublicCapabilities) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen 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 { + m.Method = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { return err } - iNdEx = postIndex + 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 *QueryPublicCapabilityResponse) 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: QueryPublicCapabilityResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPublicCapabilityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1337,7 +1590,7 @@ func (m *QueryPublicCapabilities) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPublicCapabilitiesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryRoleCapability) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1360,17 +1613,17 @@ func (m *QueryPublicCapabilitiesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPublicCapabilitiesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRoleCapability: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPublicCapabilitiesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryRoleCapability: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PublicCapabilities", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1380,29 +1633,77 @@ func (m *QueryPublicCapabilitiesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.PublicCapabilities == nil { - m.PublicCapabilities = make(map[string]bool) + m.Method = 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 *QueryRoleCapabilityResponse) 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 } - var mapkey string - var mapvalue bool - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryRoleCapabilityResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRoleCapabilityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v Role for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1412,43 +1713,44 @@ func (m *QueryPublicCapabilitiesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= uint64(b&0x7F) << shift + v |= Role(b&0x7F) << shift if b < 0x80 { break } } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthQuery - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthQuery + m.Roles = append(m.Roles, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery } - if postStringIndexmapkey > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapvaluetemp int + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(m.Roles) == 0 { + m.Roles = make([]Role, 0, elementCount) + } + for iNdEx < postIndex { + var v Role for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1458,65 +1760,16 @@ func (m *QueryPublicCapabilitiesResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - mapvaluetemp |= int(b&0x7F) << shift + v |= Role(b&0x7F) << shift if b < 0x80 { break } } - mapvalue = bool(mapvaluetemp != 0) - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + m.Roles = append(m.Roles, v) } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType) } - m.PublicCapabilities[mapkey] = mapvalue - 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:]) @@ -1538,7 +1791,7 @@ func (m *QueryPublicCapabilitiesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPublicCapability) Unmarshal(dAtA []byte) error { +func (m *QueryUserCapability) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1561,15 +1814,15 @@ func (m *QueryPublicCapability) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPublicCapability: wiretype end group for non-group") + return fmt.Errorf("proto: QueryUserCapability: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPublicCapability: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryUserCapability: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1597,7 +1850,7 @@ func (m *QueryPublicCapability) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Method = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1620,7 +1873,7 @@ func (m *QueryPublicCapability) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPublicCapabilityResponse) Unmarshal(dAtA []byte) error { +func (m *QueryUserCapabilityResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1643,32 +1896,81 @@ func (m *QueryPublicCapabilityResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPublicCapabilityResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryUserCapabilityResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPublicCapabilityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryUserCapabilityResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery + if wireType == 0 { + var v Role + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Role(b&0x7F) << shift + if b < 0x80 { + break + } } - if iNdEx >= l { + m.Roles = append(m.Roles, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break + var elementCount int + if elementCount != 0 && len(m.Roles) == 0 { + m.Roles = make([]Role, 0, elementCount) + } + for iNdEx < postIndex { + var v Role + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Role(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Roles = append(m.Roles, v) } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType) } - m.Enabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/halo/types/entitlements/query.pb.gw.go b/x/halo/types/entitlements/query.pb.gw.go index 23e2c87..06c0c09 100644 --- a/x/halo/types/entitlements/query.pb.gw.go +++ b/x/halo/types/entitlements/query.pb.gw.go @@ -69,44 +69,62 @@ func local_request_Query_Paused_0(ctx context.Context, marshaler runtime.Marshal } -var ( - filter_Query_PublicCapabilities_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_PublicCapabilities_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPublicCapabilities +func request_Query_PublicCapability_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPublicCapability var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["method"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "method") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PublicCapabilities_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.Method, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "method", err) } - msg, err := client.PublicCapabilities(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.PublicCapability(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_PublicCapabilities_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPublicCapabilities +func local_request_Query_PublicCapability_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPublicCapability var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["method"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "method") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PublicCapabilities_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.Method, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "method", err) } - msg, err := server.PublicCapabilities(ctx, &protoReq) + msg, err := server.PublicCapability(ctx, &protoReq) return msg, metadata, err } -func request_Query_PublicCapability_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPublicCapability +func request_Query_RoleCapability_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRoleCapability var metadata runtime.ServerMetadata var ( @@ -127,13 +145,13 @@ func request_Query_PublicCapability_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "method", err) } - msg, err := client.PublicCapability(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.RoleCapability(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_PublicCapability_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPublicCapability +func local_request_Query_RoleCapability_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRoleCapability var metadata runtime.ServerMetadata var ( @@ -154,7 +172,61 @@ func local_request_Query_PublicCapability_0(ctx context.Context, marshaler runti return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "method", err) } - msg, err := server.PublicCapability(ctx, &protoReq) + msg, err := server.RoleCapability(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_UserCapability_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUserCapability + 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.UserCapability(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_UserCapability_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUserCapability + 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.UserCapability(ctx, &protoReq) return msg, metadata, err } @@ -211,7 +283,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_PublicCapabilities_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PublicCapability_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -222,7 +294,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_PublicCapabilities_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_PublicCapability_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 { @@ -230,11 +302,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_PublicCapabilities_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PublicCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_PublicCapability_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_RoleCapability_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -245,7 +317,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_PublicCapability_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_RoleCapability_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 { @@ -253,7 +325,30 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_PublicCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_RoleCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_UserCapability_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_UserCapability_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_UserCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -338,7 +433,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_PublicCapabilities_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_PublicCapability_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) @@ -347,18 +442,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_PublicCapabilities_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_PublicCapability_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_PublicCapabilities_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_PublicCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_PublicCapability_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_RoleCapability_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) @@ -367,14 +462,34 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_PublicCapability_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_RoleCapability_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_PublicCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_RoleCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_UserCapability_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_UserCapability_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_UserCapability_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -386,9 +501,11 @@ var ( pattern_Query_Paused_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"halo", "entitlements", "v1", "paused"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PublicCapabilities_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"halo", "entitlements", "v1", "public_capabilities"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_PublicCapability_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"halo", "entitlements", "v1", "public_capability", "method"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RoleCapability_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"halo", "entitlements", "v1", "role_capability", "method"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_UserCapability_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"halo", "entitlements", "v1", "user_capability", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -396,7 +513,9 @@ var ( forward_Query_Paused_0 = runtime.ForwardResponseMessage - forward_Query_PublicCapabilities_0 = runtime.ForwardResponseMessage - forward_Query_PublicCapability_0 = runtime.ForwardResponseMessage + + forward_Query_RoleCapability_0 = runtime.ForwardResponseMessage + + forward_Query_UserCapability_0 = runtime.ForwardResponseMessage )