forked from cerc-io/laconicd
Add a query to list authorities (#42)
Part of [Add a CLI query to list all authorities with owner filter](cerc-io/laconicd#41) Usage: ```bash $ laconicd query registry list-authorities -h List authorities (optionally by owner) Usage: laconicd query registry list-authorities [flags] Flags: --grpc-addr string the gRPC endpoint to use for this chain --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS --height int Use a specific height to query state at (this can error if the node is pruning state) -h, --help help for list-authorities --no-indent Do not indent JSON output --node string <host>:<port> to CometBFT RPC interface for this chain (default "tcp://localhost:26657") -o, --output string Output format (text|json) (default "text") --owner string Owner to get the authorities for ``` Example: ```bash # Without owner filter $ laconicd query registry list-authorities authorities: - entry: expiry_time: "2024-07-26T06:54:28.491158167Z" height: "247" owner_address: laconic1e23vfttpvk045pqeydr4mujmlemx8hf9zjm7h2 owner_public_key: A6RlTGLIpyA8nnEQN4V3sz3uaLMY0fHtB7aS7u1zTOdD status: active name: cerc - entry: expiry_time: "2024-07-26T06:47:58.971429925Z" height: "118" owner_address: laconic10ztdu07xn7rracvzvehelgwvsytqlrvj6pvput owner_public_key: AvBxGIXBFmWCF+OHFwydqEtp2bfP+aimObO3teunbve7 status: active name: laconic # With owner filter $ laconicd query registry list-authorities --owner laconic1e23vfttpvk045pqeydr4mujmlemx8hf9zjm7h2 authorities: - entry: expiry_time: "2024-07-26T06:54:28.491158167Z" height: "247" owner_address: laconic1e23vfttpvk045pqeydr4mujmlemx8hf9zjm7h2 owner_public_key: A6RlTGLIpyA8nnEQN4V3sz3uaLMY0fHtB7aS7u1zTOdD status: active name: cerc ``` Reviewed-on: cerc-io/laconicd#42 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
+1363
-235
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@ const (
|
||||
Query_LookupLrn_FullMethodName = "/cerc.registry.v1.Query/LookupLrn"
|
||||
Query_ResolveLrn_FullMethodName = "/cerc.registry.v1.Query/ResolveLrn"
|
||||
Query_GetRegistryModuleBalance_FullMethodName = "/cerc.registry.v1.Query/GetRegistryModuleBalance"
|
||||
Query_Authorities_FullMethodName = "/cerc.registry.v1.Query/Authorities"
|
||||
)
|
||||
|
||||
// QueryClient is the client API for Query service.
|
||||
@@ -52,6 +53,8 @@ type QueryClient interface {
|
||||
ResolveLrn(ctx context.Context, in *QueryResolveLrnRequest, opts ...grpc.CallOption) (*QueryResolveLrnResponse, error)
|
||||
// Get registry module balance
|
||||
GetRegistryModuleBalance(ctx context.Context, in *QueryGetRegistryModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetRegistryModuleBalanceResponse, error)
|
||||
// Authorities queries all authorities
|
||||
Authorities(ctx context.Context, in *QueryAuthoritiesRequest, opts ...grpc.CallOption) (*QueryAuthoritiesResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
@@ -143,6 +146,15 @@ func (c *queryClient) GetRegistryModuleBalance(ctx context.Context, in *QueryGet
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) Authorities(ctx context.Context, in *QueryAuthoritiesRequest, opts ...grpc.CallOption) (*QueryAuthoritiesResponse, error) {
|
||||
out := new(QueryAuthoritiesResponse)
|
||||
err := c.cc.Invoke(ctx, Query_Authorities_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
// All implementations must embed UnimplementedQueryServer
|
||||
// for forward compatibility
|
||||
@@ -165,6 +177,8 @@ type QueryServer interface {
|
||||
ResolveLrn(context.Context, *QueryResolveLrnRequest) (*QueryResolveLrnResponse, error)
|
||||
// Get registry module balance
|
||||
GetRegistryModuleBalance(context.Context, *QueryGetRegistryModuleBalanceRequest) (*QueryGetRegistryModuleBalanceResponse, error)
|
||||
// Authorities queries all authorities
|
||||
Authorities(context.Context, *QueryAuthoritiesRequest) (*QueryAuthoritiesResponse, error)
|
||||
mustEmbedUnimplementedQueryServer()
|
||||
}
|
||||
|
||||
@@ -199,6 +213,9 @@ func (UnimplementedQueryServer) ResolveLrn(context.Context, *QueryResolveLrnRequ
|
||||
func (UnimplementedQueryServer) GetRegistryModuleBalance(context.Context, *QueryGetRegistryModuleBalanceRequest) (*QueryGetRegistryModuleBalanceResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetRegistryModuleBalance not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) Authorities(context.Context, *QueryAuthoritiesRequest) (*QueryAuthoritiesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Authorities not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
||||
|
||||
// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -374,6 +391,24 @@ func _Query_GetRegistryModuleBalance_Handler(srv interface{}, ctx context.Contex
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_Authorities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryAuthoritiesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).Authorities(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Query_Authorities_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).Authorities(ctx, req.(*QueryAuthoritiesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -417,6 +452,10 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetRegistryModuleBalance",
|
||||
Handler: _Query_GetRegistryModuleBalance_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Authorities",
|
||||
Handler: _Query_Authorities_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cerc/registry/v1/query.proto",
|
||||
|
||||
Reference in New Issue
Block a user