Skip to content

Commit

Permalink
codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed May 23, 2024
1 parent cfff16f commit 5c518a9
Show file tree
Hide file tree
Showing 6 changed files with 665 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//@ts-nocheck
import { LCDClient } from "@cosmology/lcd";
import { ListAllInterfacesRequest, ListAllInterfacesResponseSDKType, ListImplementationsRequest, ListImplementationsResponseSDKType } from "./reflection";
export class LCDQueryClient {
req: LCDClient;
constructor({
requestClient
}: {
requestClient: LCDClient;
}) {
this.req = requestClient;
this.listAllInterfaces = this.listAllInterfaces.bind(this);
this.listImplementations = this.listImplementations.bind(this);
}
/* ListAllInterfaces lists all the interfaces registered in the interface
registry. */
async listAllInterfaces(_params: ListAllInterfacesRequest = {}): Promise<ListAllInterfacesResponseSDKType> {
const endpoint = `cosmos/base/reflection/v1beta1/interfaces`;
return await this.req.get<ListAllInterfacesResponseSDKType>(endpoint);
}
/* ListImplementations list all the concrete types that implement a given
interface. */
async listImplementations(params: ListImplementationsRequest): Promise<ListImplementationsResponseSDKType> {
const endpoint = `cosmos/base/reflection/v1beta1/interfaces/${params.interfaceName}/implementations`;
return await this.req.get<ListImplementationsResponseSDKType>(endpoint);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//@ts-nocheck
import { Rpc } from "../../../../helpers";
import { BinaryReader } from "../../../../binary";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { ListAllInterfacesRequest, ListAllInterfacesResponse, ListImplementationsRequest, ListImplementationsResponse } from "./reflection";
/** ReflectionService defines a service for interface reflection. */
export interface ReflectionService {
/**
* ListAllInterfaces lists all the interfaces registered in the interface
* registry.
*/
listAllInterfaces(request?: ListAllInterfacesRequest): Promise<ListAllInterfacesResponse>;
/**
* ListImplementations list all the concrete types that implement a given
* interface.
*/
listImplementations(request: ListImplementationsRequest): Promise<ListImplementationsResponse>;
}
export class ReflectionServiceClientImpl implements ReflectionService {
private readonly rpc: Rpc;
constructor(rpc: Rpc) {
this.rpc = rpc;
this.listAllInterfaces = this.listAllInterfaces.bind(this);
this.listImplementations = this.listImplementations.bind(this);
}
listAllInterfaces(request: ListAllInterfacesRequest = {}): Promise<ListAllInterfacesResponse> {
const data = ListAllInterfacesRequest.encode(request).finish();
const promise = this.rpc.request("cosmos.base.reflection.v1beta1.ReflectionService", "ListAllInterfaces", data);
return promise.then(data => ListAllInterfacesResponse.decode(new BinaryReader(data)));
}
listImplementations(request: ListImplementationsRequest): Promise<ListImplementationsResponse> {
const data = ListImplementationsRequest.encode(request).finish();
const promise = this.rpc.request("cosmos.base.reflection.v1beta1.ReflectionService", "ListImplementations", data);
return promise.then(data => ListImplementationsResponse.decode(new BinaryReader(data)));
}
}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
const queryService = new ReflectionServiceClientImpl(rpc);
return {
listAllInterfaces(request?: ListAllInterfacesRequest): Promise<ListAllInterfacesResponse> {
return queryService.listAllInterfaces(request);
},
listImplementations(request: ListImplementationsRequest): Promise<ListImplementationsResponse> {
return queryService.listImplementations(request);
}
};
};
Loading

0 comments on commit 5c518a9

Please sign in to comment.