@burnt-labs/xion-types 25.0.0 → 25.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ //@ts-nocheck
2
+ import { setPaginationParams } from "../../../../helpers";
3
+ import { LCDClient } from "@cosmology/lcd";
4
+ import { QueryGrantsRequest, QueryGrantsResponseSDKType, QueryGranterGrantsRequest, QueryGranterGrantsResponseSDKType, QueryGranteeGrantsRequest, QueryGranteeGrantsResponseSDKType } from "./query";
5
+ export class LCDQueryClient {
6
+ req: LCDClient;
7
+ constructor({
8
+ requestClient
9
+ }: {
10
+ requestClient: LCDClient;
11
+ }) {
12
+ this.req = requestClient;
13
+ this.grants = this.grants.bind(this);
14
+ this.granterGrants = this.granterGrants.bind(this);
15
+ this.granteeGrants = this.granteeGrants.bind(this);
16
+ }
17
+ /* Returns list of `Authorization`, granted to the grantee by the granter. */
18
+ async grants(params: QueryGrantsRequest): Promise<QueryGrantsResponseSDKType> {
19
+ const options: any = {
20
+ params: {}
21
+ };
22
+ if (typeof params?.granter !== "undefined") {
23
+ options.params.granter = params.granter;
24
+ }
25
+ if (typeof params?.grantee !== "undefined") {
26
+ options.params.grantee = params.grantee;
27
+ }
28
+ if (typeof params?.msgTypeUrl !== "undefined") {
29
+ options.params.msg_type_url = params.msgTypeUrl;
30
+ }
31
+ if (typeof params?.pagination !== "undefined") {
32
+ setPaginationParams(options, params.pagination);
33
+ }
34
+ const endpoint = `xion/indexer/authz/v1/grants`;
35
+ return await this.req.get<QueryGrantsResponseSDKType>(endpoint, options);
36
+ }
37
+ /* GranterGrants returns list of `GrantAuthorization`, granted by granter.
38
+
39
+ Since: cosmos-sdk 0.46 */
40
+ async granterGrants(params: QueryGranterGrantsRequest): Promise<QueryGranterGrantsResponseSDKType> {
41
+ const options: any = {
42
+ params: {}
43
+ };
44
+ if (typeof params?.pagination !== "undefined") {
45
+ setPaginationParams(options, params.pagination);
46
+ }
47
+ const endpoint = `xion/indexer/authz/v1/grants/granter/${params.granter}`;
48
+ return await this.req.get<QueryGranterGrantsResponseSDKType>(endpoint, options);
49
+ }
50
+ /* GranteeGrants returns a list of `GrantAuthorization` by grantee.
51
+
52
+ Since: cosmos-sdk 0.46 */
53
+ async granteeGrants(params: QueryGranteeGrantsRequest): Promise<QueryGranteeGrantsResponseSDKType> {
54
+ const options: any = {
55
+ params: {}
56
+ };
57
+ if (typeof params?.pagination !== "undefined") {
58
+ setPaginationParams(options, params.pagination);
59
+ }
60
+ const endpoint = `xion/indexer/authz/v1/grants/grantee/${params.grantee}`;
61
+ return await this.req.get<QueryGranteeGrantsResponseSDKType>(endpoint, options);
62
+ }
63
+ }
@@ -0,0 +1,61 @@
1
+ //@ts-nocheck
2
+ import { Rpc } from "../../../../helpers";
3
+ import { BinaryReader } from "../../../../binary";
4
+ import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
5
+ import { QueryGrantsRequest, QueryGrantsResponse, QueryGranterGrantsRequest, QueryGranterGrantsResponse, QueryGranteeGrantsRequest, QueryGranteeGrantsResponse } from "./query";
6
+ /** Query defines the gRPC querier service. */
7
+ export interface Query {
8
+ /** Returns list of `Authorization`, granted to the grantee by the granter. */
9
+ grants(request: QueryGrantsRequest): Promise<QueryGrantsResponse>;
10
+ /**
11
+ * GranterGrants returns list of `GrantAuthorization`, granted by granter.
12
+ *
13
+ * Since: cosmos-sdk 0.46
14
+ */
15
+ granterGrants(request: QueryGranterGrantsRequest): Promise<QueryGranterGrantsResponse>;
16
+ /**
17
+ * GranteeGrants returns a list of `GrantAuthorization` by grantee.
18
+ *
19
+ * Since: cosmos-sdk 0.46
20
+ */
21
+ granteeGrants(request: QueryGranteeGrantsRequest): Promise<QueryGranteeGrantsResponse>;
22
+ }
23
+ export class QueryClientImpl implements Query {
24
+ private readonly rpc: Rpc;
25
+ constructor(rpc: Rpc) {
26
+ this.rpc = rpc;
27
+ this.grants = this.grants.bind(this);
28
+ this.granterGrants = this.granterGrants.bind(this);
29
+ this.granteeGrants = this.granteeGrants.bind(this);
30
+ }
31
+ grants(request: QueryGrantsRequest): Promise<QueryGrantsResponse> {
32
+ const data = QueryGrantsRequest.encode(request).finish();
33
+ const promise = this.rpc.request("xion.indexer.authz.v1.Query", "Grants", data);
34
+ return promise.then(data => QueryGrantsResponse.decode(new BinaryReader(data)));
35
+ }
36
+ granterGrants(request: QueryGranterGrantsRequest): Promise<QueryGranterGrantsResponse> {
37
+ const data = QueryGranterGrantsRequest.encode(request).finish();
38
+ const promise = this.rpc.request("xion.indexer.authz.v1.Query", "GranterGrants", data);
39
+ return promise.then(data => QueryGranterGrantsResponse.decode(new BinaryReader(data)));
40
+ }
41
+ granteeGrants(request: QueryGranteeGrantsRequest): Promise<QueryGranteeGrantsResponse> {
42
+ const data = QueryGranteeGrantsRequest.encode(request).finish();
43
+ const promise = this.rpc.request("xion.indexer.authz.v1.Query", "GranteeGrants", data);
44
+ return promise.then(data => QueryGranteeGrantsResponse.decode(new BinaryReader(data)));
45
+ }
46
+ }
47
+ export const createRpcQueryExtension = (base: QueryClient) => {
48
+ const rpc = createProtobufRpcClient(base);
49
+ const queryService = new QueryClientImpl(rpc);
50
+ return {
51
+ grants(request: QueryGrantsRequest): Promise<QueryGrantsResponse> {
52
+ return queryService.grants(request);
53
+ },
54
+ granterGrants(request: QueryGranterGrantsRequest): Promise<QueryGranterGrantsResponse> {
55
+ return queryService.granterGrants(request);
56
+ },
57
+ granteeGrants(request: QueryGranteeGrantsRequest): Promise<QueryGranteeGrantsResponse> {
58
+ return queryService.granteeGrants(request);
59
+ }
60
+ };
61
+ };