-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfff16f
commit 5c518a9
Showing
6 changed files
with
665 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.lcd.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; | ||
}; |
Oops, something went wrong.