Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add queries ShowAuthorization and ListAuthorizations #2312

Merged
merged 15 commits into from
Jun 6, 2024
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* [2291](https://github.com/zeta-chain/node/pull/2291) - initialize cctx gateway interface
* [2289](https://github.com/zeta-chain/node/pull/2289) - add an authorization list to keep track of all authorizations on the chain
* [2305](https://github.com/zeta-chain/node/pull/2305) - add new messages `MsgAddAuthorization` and `MsgRemoveAuthorization` that can be used to update the authorization list
* [2312](https://github.com/zeta-chain/node/pull/2312) - add queries `ShowAuthorization` and `ListAuthorizations`

### Refactor

Expand Down
2 changes: 2 additions & 0 deletions docs/cli/zetacored/zetacored_query_authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ zetacored query authority [flags]
### SEE ALSO

* [zetacored query](zetacored_query.md) - Querying subcommands
* [zetacored query authority list-authorizations](zetacored_query_authority_list-authorizations.md) - lists all authorizations
* [zetacored query authority show-authorization](zetacored_query_authority_show-authorization.md) - shows the authorization for a given message URL
* [zetacored query authority show-chain-info](zetacored_query_authority_show-chain-info.md) - show the chain info
* [zetacored query authority show-policies](zetacored_query_authority_show-policies.md) - show the policies

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# query authority list-authorizations

lists all authorizations

```
zetacored query authority list-authorizations [flags]
```

### Options

```
--grpc-addr string the gRPC endpoint to use for this chain
--grpc-insecure allow gRPC over insecure channels, if not TLS 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-authorizations
--node string [host]:[port] to Tendermint RPC interface for this chain
-o, --output string Output format (text|json)
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query authority](zetacored_query_authority.md) - Querying commands for the authority module

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# query authority show-authorization

shows the authorization for a given message URL

```
zetacored query authority show-authorization [msg-url] [flags]
```

### Options

```
--grpc-addr string the gRPC endpoint to use for this chain
--grpc-insecure allow gRPC over insecure channels, if not TLS 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 show-authorization
--node string [host]:[port] to Tendermint RPC interface for this chain
-o, --output string Output format (text|json)
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query authority](zetacored_query_authority.md) - Querying commands for the authority module

70 changes: 70 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28254,6 +28254,39 @@ paths:
type: boolean
tags:
- Query
/zeta-chain/authority/authorization/{msg_url}:
get:
operationId: Query_Authorization
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/authorityQueryAuthorizationResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: msg_url
in: path
required: true
type: string
tags:
- Query
/zeta-chain/authority/authorizations:
get:
operationId: Query_AuthorizationList
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/authorityQueryAuthorizationListResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/authority/chainInfo:
get:
summary: Queries ChainInfo
Expand Down Expand Up @@ -56718,6 +56751,27 @@ definitions:
format: int64
balance:
type: string
authorityAuthorization:
type: object
properties:
msg_url:
type: string
title: The URL of the message that needs to be authorized
authorized_policy:
$ref: '#/definitions/authorityPolicyType'
title: The policy that is authorized to access the message
title: |-
Authorization defines the authorization required to access use a message
which needs special permissions
authorityAuthorizationList:
type: object
properties:
authorizations:
type: array
items:
type: object
$ref: '#/definitions/authorityAuthorization'
title: AuthorizationList holds the list of authorizations on zetachain
authorityChainInfo:
type: object
properties:
Expand Down Expand Up @@ -56778,6 +56832,22 @@ definitions:

Used for empty policy, no action is allowed
title: PolicyType defines the type of policy
authorityQueryAuthorizationListResponse:
type: object
properties:
authorization_list:
$ref: '#/definitions/authorityAuthorizationList'
title: |-
QueryAuthorizationListResponse is the response type for the
Query/AuthorizationList RPC
authorityQueryAuthorizationResponse:
type: object
properties:
authorization:
$ref: '#/definitions/authorityAuthorization'
description: |-
QueryAuthorizationResponse is the response type for the Query/Authorization
RPC method.
authorityQueryGetChainInfoResponse:
type: object
properties:
Expand Down
31 changes: 31 additions & 0 deletions proto/zetachain/zetacore/authority/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package zetachain.zetacore.authority;

import "zetachain/zetacore/authority/policies.proto";
import "zetachain/zetacore/authority/chain_info.proto";
import "zetachain/zetacore/authority/authorization.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
Expand All @@ -20,6 +21,36 @@ service Query {
rpc ChainInfo(QueryGetChainInfoRequest) returns (QueryGetChainInfoResponse) {
option (google.api.http).get = "/zeta-chain/authority/chainInfo";
}

rpc AuthorizationList(QueryAuthorizationListRequest)
returns (QueryAuthorizationListResponse) {
option (google.api.http).get = "/zeta-chain/authority/authorizations";
}

rpc Authorization(QueryAuthorizationRequest)
returns (QueryAuthorizationResponse) {
option (google.api.http).get =
"/zeta-chain/authority/authorization/{msg_url}";
}
}

// QueryAuthorizationListRequest is the request type for the
// Query/AuthorizationList RPC method.
message QueryAuthorizationListRequest {}
// QueryAuthorizationListResponse is the response type for the
// Query/AuthorizationList RPC
message QueryAuthorizationListResponse {
AuthorizationList authorization_list = 1 [ (gogoproto.nullable) = false ];
}

// QueryAuthorizationRequest is the request type for the Query/Authorization RPC
// method.
message QueryAuthorizationRequest { string msg_url = 1; }

// QueryAuthorizationResponse is the response type for the Query/Authorization
// RPC method.
message QueryAuthorizationResponse {
Authorization authorization = 1 [ (gogoproto.nullable) = false ];
}

// QueryGetPoliciesRequest is the request type for the Query/Policies RPC
Expand Down
104 changes: 104 additions & 0 deletions typescript/zetachain/zetacore/authority/query_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,113 @@

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import type { Authorization, AuthorizationList } from "./authorization_pb.js";
import type { Policies } from "./policies_pb.js";
import type { ChainInfo } from "./chain_info_pb.js";

/**
* QueryAuthorizationListRequest is the request type for the
* Query/AuthorizationList RPC method.
*
* @generated from message zetachain.zetacore.authority.QueryAuthorizationListRequest
*/
export declare class QueryAuthorizationListRequest extends Message<QueryAuthorizationListRequest> {
constructor(data?: PartialMessage<QueryAuthorizationListRequest>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.authority.QueryAuthorizationListRequest";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryAuthorizationListRequest;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryAuthorizationListRequest;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryAuthorizationListRequest;

static equals(a: QueryAuthorizationListRequest | PlainMessage<QueryAuthorizationListRequest> | undefined, b: QueryAuthorizationListRequest | PlainMessage<QueryAuthorizationListRequest> | undefined): boolean;
}

/**
* QueryAuthorizationListResponse is the response type for the
* Query/AuthorizationList RPC
*
* @generated from message zetachain.zetacore.authority.QueryAuthorizationListResponse
*/
export declare class QueryAuthorizationListResponse extends Message<QueryAuthorizationListResponse> {
/**
* @generated from field: zetachain.zetacore.authority.AuthorizationList authorization_list = 1;
*/
authorizationList?: AuthorizationList;

constructor(data?: PartialMessage<QueryAuthorizationListResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.authority.QueryAuthorizationListResponse";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryAuthorizationListResponse;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryAuthorizationListResponse;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryAuthorizationListResponse;

static equals(a: QueryAuthorizationListResponse | PlainMessage<QueryAuthorizationListResponse> | undefined, b: QueryAuthorizationListResponse | PlainMessage<QueryAuthorizationListResponse> | undefined): boolean;
}

/**
* QueryAuthorizationRequest is the request type for the Query/Authorization RPC
* method.
*
* @generated from message zetachain.zetacore.authority.QueryAuthorizationRequest
*/
export declare class QueryAuthorizationRequest extends Message<QueryAuthorizationRequest> {
/**
* @generated from field: string msg_url = 1;
*/
msgUrl: string;

constructor(data?: PartialMessage<QueryAuthorizationRequest>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.authority.QueryAuthorizationRequest";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryAuthorizationRequest;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryAuthorizationRequest;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryAuthorizationRequest;

static equals(a: QueryAuthorizationRequest | PlainMessage<QueryAuthorizationRequest> | undefined, b: QueryAuthorizationRequest | PlainMessage<QueryAuthorizationRequest> | undefined): boolean;
}

/**
* QueryAuthorizationResponse is the response type for the Query/Authorization
* RPC method.
*
* @generated from message zetachain.zetacore.authority.QueryAuthorizationResponse
*/
export declare class QueryAuthorizationResponse extends Message<QueryAuthorizationResponse> {
/**
* @generated from field: zetachain.zetacore.authority.Authorization authorization = 1;
*/
authorization?: Authorization;

constructor(data?: PartialMessage<QueryAuthorizationResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "zetachain.zetacore.authority.QueryAuthorizationResponse";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryAuthorizationResponse;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryAuthorizationResponse;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryAuthorizationResponse;

static equals(a: QueryAuthorizationResponse | PlainMessage<QueryAuthorizationResponse> | undefined, b: QueryAuthorizationResponse | PlainMessage<QueryAuthorizationResponse> | undefined): boolean;
}

/**
* QueryGetPoliciesRequest is the request type for the Query/Policies RPC
* method.
Expand Down
2 changes: 2 additions & 0 deletions x/authority/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func GetQueryCmd(_ string) *cobra.Command {
cmd.AddCommand(
CmdShowPolicies(),
CmdShowChainInfo(),
CmdAuthorizationsList(),
CmdAuthorization(),
)

return cmd
Expand Down
Loading
Loading