From 5c518a932428696dc693bbbea75207a006ab2612 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Thu, 23 May 2024 10:25:20 +0200 Subject: [PATCH] codegen --- .../base/reflection/v1beta1/reflection.lcd.ts | 27 ++ .../reflection.rpc.ReflectionService.ts | 48 ++ .../base/reflection/v1beta1/reflection.ts | 414 ++++++++++++++++++ .../reflection/v2alpha1/reflection.lcd.ts | 51 +++ .../reflection.rpc.ReflectionService.ts | 90 ++++ .../v1/reflection.rpc.ReflectionService.ts | 35 ++ 6 files changed, 665 insertions(+) create mode 100644 packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.lcd.ts create mode 100644 packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts create mode 100644 packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.ts create mode 100644 packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.lcd.ts create mode 100644 packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts create mode 100644 packages/osmojs/src/cosmos/reflection/v1/reflection.rpc.ReflectionService.ts diff --git a/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.lcd.ts b/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.lcd.ts new file mode 100644 index 00000000..8e6ad0f0 --- /dev/null +++ b/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.lcd.ts @@ -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 { + const endpoint = `cosmos/base/reflection/v1beta1/interfaces`; + return await this.req.get(endpoint); + } + /* ListImplementations list all the concrete types that implement a given + interface. */ + async listImplementations(params: ListImplementationsRequest): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/interfaces/${params.interfaceName}/implementations`; + return await this.req.get(endpoint); + } +} \ No newline at end of file diff --git a/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts b/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts new file mode 100644 index 00000000..9fdc7785 --- /dev/null +++ b/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts @@ -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; + /** + * ListImplementations list all the concrete types that implement a given + * interface. + */ + listImplementations(request: ListImplementationsRequest): Promise; +} +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 { + 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 { + 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 { + return queryService.listAllInterfaces(request); + }, + listImplementations(request: ListImplementationsRequest): Promise { + return queryService.listImplementations(request); + } + }; +}; \ No newline at end of file diff --git a/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.ts b/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.ts new file mode 100644 index 00000000..c8f00ea6 --- /dev/null +++ b/packages/osmojs/src/cosmos/base/reflection/v1beta1/reflection.ts @@ -0,0 +1,414 @@ +//@ts-nocheck +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { GlobalDecoderRegistry } from "../../../../registry"; +/** ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. */ +export interface ListAllInterfacesRequest {} +export interface ListAllInterfacesRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesRequest"; + value: Uint8Array; +} +/** ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. */ +export interface ListAllInterfacesRequestAmino {} +export interface ListAllInterfacesRequestAminoMsg { + type: "cosmos-sdk/ListAllInterfacesRequest"; + value: ListAllInterfacesRequestAmino; +} +/** ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. */ +export interface ListAllInterfacesRequestSDKType {} +/** ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. */ +export interface ListAllInterfacesResponse { + /** interface_names is an array of all the registered interfaces. */ + interfaceNames: string[]; +} +export interface ListAllInterfacesResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesResponse"; + value: Uint8Array; +} +/** ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. */ +export interface ListAllInterfacesResponseAmino { + /** interface_names is an array of all the registered interfaces. */ + interface_names?: string[]; +} +export interface ListAllInterfacesResponseAminoMsg { + type: "cosmos-sdk/ListAllInterfacesResponse"; + value: ListAllInterfacesResponseAmino; +} +/** ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. */ +export interface ListAllInterfacesResponseSDKType { + interface_names: string[]; +} +/** + * ListImplementationsRequest is the request type of the ListImplementations + * RPC. + */ +export interface ListImplementationsRequest { + /** interface_name defines the interface to query the implementations for. */ + interfaceName: string; +} +export interface ListImplementationsRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsRequest"; + value: Uint8Array; +} +/** + * ListImplementationsRequest is the request type of the ListImplementations + * RPC. + */ +export interface ListImplementationsRequestAmino { + /** interface_name defines the interface to query the implementations for. */ + interface_name?: string; +} +export interface ListImplementationsRequestAminoMsg { + type: "cosmos-sdk/ListImplementationsRequest"; + value: ListImplementationsRequestAmino; +} +/** + * ListImplementationsRequest is the request type of the ListImplementations + * RPC. + */ +export interface ListImplementationsRequestSDKType { + interface_name: string; +} +/** + * ListImplementationsResponse is the response type of the ListImplementations + * RPC. + */ +export interface ListImplementationsResponse { + implementationMessageNames: string[]; +} +export interface ListImplementationsResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsResponse"; + value: Uint8Array; +} +/** + * ListImplementationsResponse is the response type of the ListImplementations + * RPC. + */ +export interface ListImplementationsResponseAmino { + implementation_message_names?: string[]; +} +export interface ListImplementationsResponseAminoMsg { + type: "cosmos-sdk/ListImplementationsResponse"; + value: ListImplementationsResponseAmino; +} +/** + * ListImplementationsResponse is the response type of the ListImplementations + * RPC. + */ +export interface ListImplementationsResponseSDKType { + implementation_message_names: string[]; +} +function createBaseListAllInterfacesRequest(): ListAllInterfacesRequest { + return {}; +} +export const ListAllInterfacesRequest = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesRequest", + aminoType: "cosmos-sdk/ListAllInterfacesRequest", + is(o: any): o is ListAllInterfacesRequest { + return o && o.$typeUrl === ListAllInterfacesRequest.typeUrl; + }, + isSDK(o: any): o is ListAllInterfacesRequestSDKType { + return o && o.$typeUrl === ListAllInterfacesRequest.typeUrl; + }, + isAmino(o: any): o is ListAllInterfacesRequestAmino { + return o && o.$typeUrl === ListAllInterfacesRequest.typeUrl; + }, + encode(_: ListAllInterfacesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListAllInterfacesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListAllInterfacesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromPartial(_: Partial): ListAllInterfacesRequest { + const message = createBaseListAllInterfacesRequest(); + return message; + }, + fromAmino(_: ListAllInterfacesRequestAmino): ListAllInterfacesRequest { + const message = createBaseListAllInterfacesRequest(); + return message; + }, + toAmino(_: ListAllInterfacesRequest): ListAllInterfacesRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: ListAllInterfacesRequestAminoMsg): ListAllInterfacesRequest { + return ListAllInterfacesRequest.fromAmino(object.value); + }, + toAminoMsg(message: ListAllInterfacesRequest): ListAllInterfacesRequestAminoMsg { + return { + type: "cosmos-sdk/ListAllInterfacesRequest", + value: ListAllInterfacesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: ListAllInterfacesRequestProtoMsg): ListAllInterfacesRequest { + return ListAllInterfacesRequest.decode(message.value); + }, + toProto(message: ListAllInterfacesRequest): Uint8Array { + return ListAllInterfacesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListAllInterfacesRequest): ListAllInterfacesRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesRequest", + value: ListAllInterfacesRequest.encode(message).finish() + }; + } +}; +GlobalDecoderRegistry.register(ListAllInterfacesRequest.typeUrl, ListAllInterfacesRequest); +GlobalDecoderRegistry.registerAminoProtoMapping(ListAllInterfacesRequest.aminoType, ListAllInterfacesRequest.typeUrl); +function createBaseListAllInterfacesResponse(): ListAllInterfacesResponse { + return { + interfaceNames: [] + }; +} +export const ListAllInterfacesResponse = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesResponse", + aminoType: "cosmos-sdk/ListAllInterfacesResponse", + is(o: any): o is ListAllInterfacesResponse { + return o && (o.$typeUrl === ListAllInterfacesResponse.typeUrl || Array.isArray(o.interfaceNames) && (!o.interfaceNames.length || typeof o.interfaceNames[0] === "string")); + }, + isSDK(o: any): o is ListAllInterfacesResponseSDKType { + return o && (o.$typeUrl === ListAllInterfacesResponse.typeUrl || Array.isArray(o.interface_names) && (!o.interface_names.length || typeof o.interface_names[0] === "string")); + }, + isAmino(o: any): o is ListAllInterfacesResponseAmino { + return o && (o.$typeUrl === ListAllInterfacesResponse.typeUrl || Array.isArray(o.interface_names) && (!o.interface_names.length || typeof o.interface_names[0] === "string")); + }, + encode(message: ListAllInterfacesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.interfaceNames) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListAllInterfacesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListAllInterfacesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.interfaceNames.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromPartial(object: Partial): ListAllInterfacesResponse { + const message = createBaseListAllInterfacesResponse(); + message.interfaceNames = object.interfaceNames?.map(e => e) || []; + return message; + }, + fromAmino(object: ListAllInterfacesResponseAmino): ListAllInterfacesResponse { + const message = createBaseListAllInterfacesResponse(); + message.interfaceNames = object.interface_names?.map(e => e) || []; + return message; + }, + toAmino(message: ListAllInterfacesResponse): ListAllInterfacesResponseAmino { + const obj: any = {}; + if (message.interfaceNames) { + obj.interface_names = message.interfaceNames.map(e => e); + } else { + obj.interface_names = message.interfaceNames; + } + return obj; + }, + fromAminoMsg(object: ListAllInterfacesResponseAminoMsg): ListAllInterfacesResponse { + return ListAllInterfacesResponse.fromAmino(object.value); + }, + toAminoMsg(message: ListAllInterfacesResponse): ListAllInterfacesResponseAminoMsg { + return { + type: "cosmos-sdk/ListAllInterfacesResponse", + value: ListAllInterfacesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: ListAllInterfacesResponseProtoMsg): ListAllInterfacesResponse { + return ListAllInterfacesResponse.decode(message.value); + }, + toProto(message: ListAllInterfacesResponse): Uint8Array { + return ListAllInterfacesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListAllInterfacesResponse): ListAllInterfacesResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesResponse", + value: ListAllInterfacesResponse.encode(message).finish() + }; + } +}; +GlobalDecoderRegistry.register(ListAllInterfacesResponse.typeUrl, ListAllInterfacesResponse); +GlobalDecoderRegistry.registerAminoProtoMapping(ListAllInterfacesResponse.aminoType, ListAllInterfacesResponse.typeUrl); +function createBaseListImplementationsRequest(): ListImplementationsRequest { + return { + interfaceName: "" + }; +} +export const ListImplementationsRequest = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsRequest", + aminoType: "cosmos-sdk/ListImplementationsRequest", + is(o: any): o is ListImplementationsRequest { + return o && (o.$typeUrl === ListImplementationsRequest.typeUrl || typeof o.interfaceName === "string"); + }, + isSDK(o: any): o is ListImplementationsRequestSDKType { + return o && (o.$typeUrl === ListImplementationsRequest.typeUrl || typeof o.interface_name === "string"); + }, + isAmino(o: any): o is ListImplementationsRequestAmino { + return o && (o.$typeUrl === ListImplementationsRequest.typeUrl || typeof o.interface_name === "string"); + }, + encode(message: ListImplementationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.interfaceName !== "") { + writer.uint32(10).string(message.interfaceName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListImplementationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListImplementationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.interfaceName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromPartial(object: Partial): ListImplementationsRequest { + const message = createBaseListImplementationsRequest(); + message.interfaceName = object.interfaceName ?? ""; + return message; + }, + fromAmino(object: ListImplementationsRequestAmino): ListImplementationsRequest { + const message = createBaseListImplementationsRequest(); + if (object.interface_name !== undefined && object.interface_name !== null) { + message.interfaceName = object.interface_name; + } + return message; + }, + toAmino(message: ListImplementationsRequest): ListImplementationsRequestAmino { + const obj: any = {}; + obj.interface_name = message.interfaceName === "" ? undefined : message.interfaceName; + return obj; + }, + fromAminoMsg(object: ListImplementationsRequestAminoMsg): ListImplementationsRequest { + return ListImplementationsRequest.fromAmino(object.value); + }, + toAminoMsg(message: ListImplementationsRequest): ListImplementationsRequestAminoMsg { + return { + type: "cosmos-sdk/ListImplementationsRequest", + value: ListImplementationsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: ListImplementationsRequestProtoMsg): ListImplementationsRequest { + return ListImplementationsRequest.decode(message.value); + }, + toProto(message: ListImplementationsRequest): Uint8Array { + return ListImplementationsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListImplementationsRequest): ListImplementationsRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsRequest", + value: ListImplementationsRequest.encode(message).finish() + }; + } +}; +GlobalDecoderRegistry.register(ListImplementationsRequest.typeUrl, ListImplementationsRequest); +GlobalDecoderRegistry.registerAminoProtoMapping(ListImplementationsRequest.aminoType, ListImplementationsRequest.typeUrl); +function createBaseListImplementationsResponse(): ListImplementationsResponse { + return { + implementationMessageNames: [] + }; +} +export const ListImplementationsResponse = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsResponse", + aminoType: "cosmos-sdk/ListImplementationsResponse", + is(o: any): o is ListImplementationsResponse { + return o && (o.$typeUrl === ListImplementationsResponse.typeUrl || Array.isArray(o.implementationMessageNames) && (!o.implementationMessageNames.length || typeof o.implementationMessageNames[0] === "string")); + }, + isSDK(o: any): o is ListImplementationsResponseSDKType { + return o && (o.$typeUrl === ListImplementationsResponse.typeUrl || Array.isArray(o.implementation_message_names) && (!o.implementation_message_names.length || typeof o.implementation_message_names[0] === "string")); + }, + isAmino(o: any): o is ListImplementationsResponseAmino { + return o && (o.$typeUrl === ListImplementationsResponse.typeUrl || Array.isArray(o.implementation_message_names) && (!o.implementation_message_names.length || typeof o.implementation_message_names[0] === "string")); + }, + encode(message: ListImplementationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.implementationMessageNames) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListImplementationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListImplementationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.implementationMessageNames.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromPartial(object: Partial): ListImplementationsResponse { + const message = createBaseListImplementationsResponse(); + message.implementationMessageNames = object.implementationMessageNames?.map(e => e) || []; + return message; + }, + fromAmino(object: ListImplementationsResponseAmino): ListImplementationsResponse { + const message = createBaseListImplementationsResponse(); + message.implementationMessageNames = object.implementation_message_names?.map(e => e) || []; + return message; + }, + toAmino(message: ListImplementationsResponse): ListImplementationsResponseAmino { + const obj: any = {}; + if (message.implementationMessageNames) { + obj.implementation_message_names = message.implementationMessageNames.map(e => e); + } else { + obj.implementation_message_names = message.implementationMessageNames; + } + return obj; + }, + fromAminoMsg(object: ListImplementationsResponseAminoMsg): ListImplementationsResponse { + return ListImplementationsResponse.fromAmino(object.value); + }, + toAminoMsg(message: ListImplementationsResponse): ListImplementationsResponseAminoMsg { + return { + type: "cosmos-sdk/ListImplementationsResponse", + value: ListImplementationsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: ListImplementationsResponseProtoMsg): ListImplementationsResponse { + return ListImplementationsResponse.decode(message.value); + }, + toProto(message: ListImplementationsResponse): Uint8Array { + return ListImplementationsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListImplementationsResponse): ListImplementationsResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsResponse", + value: ListImplementationsResponse.encode(message).finish() + }; + } +}; +GlobalDecoderRegistry.register(ListImplementationsResponse.typeUrl, ListImplementationsResponse); +GlobalDecoderRegistry.registerAminoProtoMapping(ListImplementationsResponse.aminoType, ListImplementationsResponse.typeUrl); \ No newline at end of file diff --git a/packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.lcd.ts b/packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.lcd.ts new file mode 100644 index 00000000..6efecb08 --- /dev/null +++ b/packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.lcd.ts @@ -0,0 +1,51 @@ +//@ts-nocheck +import { LCDClient } from "@cosmology/lcd"; +import { GetAuthnDescriptorRequest, GetAuthnDescriptorResponseSDKType, GetChainDescriptorRequest, GetChainDescriptorResponseSDKType, GetCodecDescriptorRequest, GetCodecDescriptorResponseSDKType, GetConfigurationDescriptorRequest, GetConfigurationDescriptorResponseSDKType, GetQueryServicesDescriptorRequest, GetQueryServicesDescriptorResponseSDKType, GetTxDescriptorRequest, GetTxDescriptorResponseSDKType } from "./reflection"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.getAuthnDescriptor = this.getAuthnDescriptor.bind(this); + this.getChainDescriptor = this.getChainDescriptor.bind(this); + this.getCodecDescriptor = this.getCodecDescriptor.bind(this); + this.getConfigurationDescriptor = this.getConfigurationDescriptor.bind(this); + this.getQueryServicesDescriptor = this.getQueryServicesDescriptor.bind(this); + this.getTxDescriptor = this.getTxDescriptor.bind(this); + } + /* GetAuthnDescriptor returns information on how to authenticate transactions in the application + NOTE: this RPC is still experimental and might be subject to breaking changes or removal in + future releases of the cosmos-sdk. */ + async getAuthnDescriptor(_params: GetAuthnDescriptorRequest = {}): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/app_descriptor/authn`; + return await this.req.get(endpoint); + } + /* GetChainDescriptor returns the description of the chain */ + async getChainDescriptor(_params: GetChainDescriptorRequest = {}): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/app_descriptor/chain`; + return await this.req.get(endpoint); + } + /* GetCodecDescriptor returns the descriptor of the codec of the application */ + async getCodecDescriptor(_params: GetCodecDescriptorRequest = {}): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/app_descriptor/codec`; + return await this.req.get(endpoint); + } + /* GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application */ + async getConfigurationDescriptor(_params: GetConfigurationDescriptorRequest = {}): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/app_descriptor/configuration`; + return await this.req.get(endpoint); + } + /* GetQueryServicesDescriptor returns the available gRPC queryable services of the application */ + async getQueryServicesDescriptor(_params: GetQueryServicesDescriptorRequest = {}): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/app_descriptor/query_services`; + return await this.req.get(endpoint); + } + /* GetTxDescriptor returns information on the used transaction object and available msgs that can be used */ + async getTxDescriptor(_params: GetTxDescriptorRequest = {}): Promise { + const endpoint = `cosmos/base/reflection/v1beta1/app_descriptor/tx_descriptor`; + return await this.req.get(endpoint); + } +} \ No newline at end of file diff --git a/packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts b/packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts new file mode 100644 index 00000000..e5caa96f --- /dev/null +++ b/packages/osmojs/src/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts @@ -0,0 +1,90 @@ +//@ts-nocheck +import { Rpc } from "../../../../helpers"; +import { BinaryReader } from "../../../../binary"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { GetAuthnDescriptorRequest, GetAuthnDescriptorResponse, GetChainDescriptorRequest, GetChainDescriptorResponse, GetCodecDescriptorRequest, GetCodecDescriptorResponse, GetConfigurationDescriptorRequest, GetConfigurationDescriptorResponse, GetQueryServicesDescriptorRequest, GetQueryServicesDescriptorResponse, GetTxDescriptorRequest, GetTxDescriptorResponse } from "./reflection"; +/** ReflectionService defines a service for application reflection. */ +export interface ReflectionService { + /** + * GetAuthnDescriptor returns information on how to authenticate transactions in the application + * NOTE: this RPC is still experimental and might be subject to breaking changes or removal in + * future releases of the cosmos-sdk. + */ + getAuthnDescriptor(request?: GetAuthnDescriptorRequest): Promise; + /** GetChainDescriptor returns the description of the chain */ + getChainDescriptor(request?: GetChainDescriptorRequest): Promise; + /** GetCodecDescriptor returns the descriptor of the codec of the application */ + getCodecDescriptor(request?: GetCodecDescriptorRequest): Promise; + /** GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application */ + getConfigurationDescriptor(request?: GetConfigurationDescriptorRequest): Promise; + /** GetQueryServicesDescriptor returns the available gRPC queryable services of the application */ + getQueryServicesDescriptor(request?: GetQueryServicesDescriptorRequest): Promise; + /** GetTxDescriptor returns information on the used transaction object and available msgs that can be used */ + getTxDescriptor(request?: GetTxDescriptorRequest): Promise; +} +export class ReflectionServiceClientImpl implements ReflectionService { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.getAuthnDescriptor = this.getAuthnDescriptor.bind(this); + this.getChainDescriptor = this.getChainDescriptor.bind(this); + this.getCodecDescriptor = this.getCodecDescriptor.bind(this); + this.getConfigurationDescriptor = this.getConfigurationDescriptor.bind(this); + this.getQueryServicesDescriptor = this.getQueryServicesDescriptor.bind(this); + this.getTxDescriptor = this.getTxDescriptor.bind(this); + } + getAuthnDescriptor(request: GetAuthnDescriptorRequest = {}): Promise { + const data = GetAuthnDescriptorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.reflection.v2alpha1.ReflectionService", "GetAuthnDescriptor", data); + return promise.then(data => GetAuthnDescriptorResponse.decode(new BinaryReader(data))); + } + getChainDescriptor(request: GetChainDescriptorRequest = {}): Promise { + const data = GetChainDescriptorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.reflection.v2alpha1.ReflectionService", "GetChainDescriptor", data); + return promise.then(data => GetChainDescriptorResponse.decode(new BinaryReader(data))); + } + getCodecDescriptor(request: GetCodecDescriptorRequest = {}): Promise { + const data = GetCodecDescriptorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.reflection.v2alpha1.ReflectionService", "GetCodecDescriptor", data); + return promise.then(data => GetCodecDescriptorResponse.decode(new BinaryReader(data))); + } + getConfigurationDescriptor(request: GetConfigurationDescriptorRequest = {}): Promise { + const data = GetConfigurationDescriptorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.reflection.v2alpha1.ReflectionService", "GetConfigurationDescriptor", data); + return promise.then(data => GetConfigurationDescriptorResponse.decode(new BinaryReader(data))); + } + getQueryServicesDescriptor(request: GetQueryServicesDescriptorRequest = {}): Promise { + const data = GetQueryServicesDescriptorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.reflection.v2alpha1.ReflectionService", "GetQueryServicesDescriptor", data); + return promise.then(data => GetQueryServicesDescriptorResponse.decode(new BinaryReader(data))); + } + getTxDescriptor(request: GetTxDescriptorRequest = {}): Promise { + const data = GetTxDescriptorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.reflection.v2alpha1.ReflectionService", "GetTxDescriptor", data); + return promise.then(data => GetTxDescriptorResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new ReflectionServiceClientImpl(rpc); + return { + getAuthnDescriptor(request?: GetAuthnDescriptorRequest): Promise { + return queryService.getAuthnDescriptor(request); + }, + getChainDescriptor(request?: GetChainDescriptorRequest): Promise { + return queryService.getChainDescriptor(request); + }, + getCodecDescriptor(request?: GetCodecDescriptorRequest): Promise { + return queryService.getCodecDescriptor(request); + }, + getConfigurationDescriptor(request?: GetConfigurationDescriptorRequest): Promise { + return queryService.getConfigurationDescriptor(request); + }, + getQueryServicesDescriptor(request?: GetQueryServicesDescriptorRequest): Promise { + return queryService.getQueryServicesDescriptor(request); + }, + getTxDescriptor(request?: GetTxDescriptorRequest): Promise { + return queryService.getTxDescriptor(request); + } + }; +}; \ No newline at end of file diff --git a/packages/osmojs/src/cosmos/reflection/v1/reflection.rpc.ReflectionService.ts b/packages/osmojs/src/cosmos/reflection/v1/reflection.rpc.ReflectionService.ts new file mode 100644 index 00000000..40d810aa --- /dev/null +++ b/packages/osmojs/src/cosmos/reflection/v1/reflection.rpc.ReflectionService.ts @@ -0,0 +1,35 @@ +//@ts-nocheck +import { Rpc } from "../../../helpers"; +import { BinaryReader } from "../../../binary"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { FileDescriptorsRequest, FileDescriptorsResponse } from "./reflection"; +/** Package cosmos.reflection.v1 provides support for inspecting protobuf + file descriptors. */ +export interface ReflectionService { + /** + * FileDescriptors queries all the file descriptors in the app in order + * to enable easier generation of dynamic clients. + */ + fileDescriptors(request?: FileDescriptorsRequest): Promise; +} +export class ReflectionServiceClientImpl implements ReflectionService { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.fileDescriptors = this.fileDescriptors.bind(this); + } + fileDescriptors(request: FileDescriptorsRequest = {}): Promise { + const data = FileDescriptorsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.reflection.v1.ReflectionService", "FileDescriptors", data); + return promise.then(data => FileDescriptorsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new ReflectionServiceClientImpl(rpc); + return { + fileDescriptors(request?: FileDescriptorsRequest): Promise { + return queryService.fileDescriptors(request); + } + }; +}; \ No newline at end of file